<template>
  <div class="page-container page-container-create">
    <div class="breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>营销中心</el-breadcrumb-item>
        <el-breadcrumb-item>通用促销</el-breadcrumb-item>
        <el-breadcrumb-item>编辑红包</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <p class="font22 mb20">创建红包</p>

    <div class="stepset stepset1" >
      <ul>
        <li :class="{'active':active>=1}"><span>1</span><p>设置红包规则</p></li>
        <li :class="{'active':active>=2}"><span>2</span><p>商品限制</p></li>
        <li :class="{'active':active>=3}"><span>3</span><p>触发场景</p></li>
        <li :class="{'active':active>=4}"><span>4</span><p>创建成功</p></li>
      </ul>
    </div>

    <div v-show="active == 1" class="content create_stepOne createSet create_stepAlso">
      <el-form
        :inline="true"
        :model="dataForm"
        :rules="dataFormRules"
        ref="dataForm"
        label-width="140px"
      >
        <div>
          <div class="title">基本信息：</div>
          <div class="item">
            <el-row class="m_b30">
              <el-form-item label="活动名称：" prop="promName" class="wid color999">
                <!-- <span>中文 </span> -->
                <el-input
                  clearable
                  type="text"
                  v-model.trim="dataForm.promName"
                  placeholder="请输入3-60个字符之间"
                  size="mini"
                  class="input"
                />
              </el-form-item>
            </el-row>

            <el-row class="m_b30">
              <el-form-item label="活动日期：" prop="activityTime" class="wid w450">
                <el-date-picker
                  v-model="dataForm.activityTime"
                  type="datetimerange"
                  range-separator="至"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                  @change="activityTime"
                  :picker-options="timeCheck"
                  :size="size"
                ></el-date-picker>
              </el-form-item>
            </el-row>

            <el-row class="m_b60">
              <el-form-item label="活动标签：" prop="label" class="wid">
                <el-select v-model="dataForm.label" placeholder="请选择" size="mini" clearable class="width450">
                  <el-option
                    v-for="item in tagsList"
                    :key="item.id"
                    :label="item.tagName"
                    :value="item.id"
                  ></el-option>
                </el-select>
                <el-button type="primary" @click="addtags" size="mini" class="searchButton">添加标签</el-button>
              </el-form-item>
            </el-row>
          </div>
        </div>

        <div class="w100">
          <div class="title">活动规则：</div>
          <div class="item">
            <!-- <el-row class="m_b30 labelAlignment">
              <el-form-item label="红包种类：" prop="couponType" class="wid">
                <el-radio-group v-model="dataForm.couponType">
                  <el-radio label="0" value="0" class="form-radio m_r45 radioAlignment">电子券</el-radio>
                  <el-radio label="1" value="1" class="form-radio m_r45 radioAlignment">实体券</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-row> -->

            <el-row class="m_b30 labelAlignment">
              <el-form-item label="金额抵扣类型：" prop="amountDeductType" class="wid">
                <el-radio-group v-model="dataForm.amountDeductType">
                  <el-radio label="0" value="0" class="form-radio mr40 radioAlignment noMarginLeft" border>商品红包</el-radio>
                  <el-radio label="1" value="1" class="form-radio mr40 radioAlignment noMarginLeft" border>运费红包</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-row>

            <!-- <el-row class="m_b30 labelAlignment">
              <el-form-item label="优惠方式：" prop="couponMode" class="wid">
                <el-radio-group v-model="dataForm.couponMode" @change="changeCouponMode">
                  <el-radio label="0" value="0" class="form-radio m_r45 radioAlignment">金额券</el-radio>
                  <el-radio label="1" value="1" class="form-radio m_r45 radioAlignment">折扣券</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-row> -->

            <el-row class="ways labelAlignment activityDesc">
              <el-form-item label="作用限制：" prop="limitOfAction" class="wid">
                <el-radio
                  v-model="dataForm.limitOfAction"
                  label="0"
                  value="0"
                  class="form-radio mr10 radioAlignment w130 t_l"
                  border
                >结算价</el-radio>
                <el-tooltip class="item mt7" effect="dark" content="结算价：就是几种商品价格的价总计" placement="right">
                  <span class="tipsInfo">!</span>
               </el-tooltip>
              </el-form-item>
            </el-row>
            <!-- <el-row class="m_b30">
              <el-form-item label class="wid">
                <div class="desc2 color666">结算价：就是几种商品价格的价总计</div>
              </el-form-item>
            </el-row> -->

            <el-row class="m_b30">
              <template v-if="promotionMethod">
                <el-form-item label="红包面值：" prop="couponAmount" class="wid m_b30">
                  <el-input
                    type="text"
                    clearable
                    v-model="dataForm.couponAmount"
                    maxlength="10"
                    placeholder="红包面值(元)"
                    class="width450"
                  />
                </el-form-item>
                <span class="s1">元</span>
              </template>
              <template v-if="discountMethod">
                <el-form-item label="优惠折扣：" prop="couponAmount" class="wid">
                  <el-input
                    type="text"
                    v-model="dataForm.couponAmount"
                    maxlength="10"
                    placeholder="优惠折扣"
                    class="width450"
                  />
                </el-form-item>
                <span class="s1">折</span>
              </template>
            </el-row>

            <el-row>
              <el-form-item label="发行数量：" class="wid activityDesc" prop="grantTotalNum">
                <el-input
                  clearable
                  type="text"
                  v-model="dataForm.grantTotalNum"
                  maxlength="10"
                  placeholder="发行总量(张)"
                  oninput="value=value.replace(/[^\d]/g,'')"
                  class="width450"
                />
              </el-form-item>
              <span class="s1 font16 color333">张</span>
            </el-row>
            <el-row class="m_b30">
              <el-form-item label class="wid">
                <div class="desc2 color666">注: 不填写表示无限制</div>
              </el-form-item>
            </el-row>

            <el-row class="m_b30">
              <el-form-item label="使用时间设置：" prop="couponUseTime" class="wid w450">
                <el-date-picker
                  v-model="dataForm.couponUseTime"
                  type="datetimerange"
                  range-separator="至"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                  @change="start_time"
                  :picker-options="timeCheck"
                  :size="size"
                ></el-date-picker>
              </el-form-item>
            </el-row>

            <el-row class="m_b30">
              <el-form-item label="使用条件：" prop="useTotalAmountLimit" class="wid">
                <el-input
                  clearable
                  v-model="dataForm.useTotalAmountLimit"
                  auto-complete="off"
                  type="text"
                  maxlength="10"
                  :size="size"
                  class="width450"
                ></el-input>
              </el-form-item>
              <span class="s1 font16 color333">元使用</span>
            </el-row>

            <el-row>
              <el-form-item label="领取条件：" class="wid">
                <div class="m_b30">
                  <el-form-item prop="idLimitNum">
                    <el-input
                      clearable
                      type="text"
                      v-model="dataForm.idLimitNum"
                      oninput="value=value.replace(/[^\d]/g,'')"
                      maxlength="10"
                      placeholder="不填写表示不限制"
                      class="width450"
                    />
                  </el-form-item>
                  <span class="s1 font16 color333">张（每ID总共可以领取）</span>
                </div>

                <div class="m_b30">
                  <el-form-item prop="idLimitDayNum">
                    <el-input
                      clearable
                      type="text"
                      v-model="dataForm.idLimitDayNum"
                      oninput="value=value.replace(/[^\d]/g,'')"
                      maxlength="10"
                      placeholder="不填写表示不限制"
                      class="width450"
                    />
                  </el-form-item>
                  <span class="s1 font16 color333">张（每ID总共可以领取）</span>
                </div>
              </el-form-item>
            </el-row>

            <el-row class="ways labelAlignment">
              <el-form-item label="活动描述：" prop="chineseDesc" class="wid">
                <el-input type="textarea" v-model="dataForm.chineseDesc" placeholder="最多输入100个字符"  class="activityDesc" maxlength="100"></el-input>
              </el-form-item>
            </el-row>

            <el-row class="m_b60">
                <el-form-item label class="wid">
                  <div
                    class="desc color666"
                  >注：非必填字段，不填将显示系统默认文案（会存在某些促销类型无系统默认文案）。自定义输入活动规则描述描述后将显示在前台商品详情页中，请慎重填写。</div>
                </el-form-item>
              </el-row>
          </div>
        </div>

        <div class="w100" v-if="deptType != 3">
          <div class="title">交易规则：</div>
          <div class="m_b30">
            <el-row class="m_b60 ways labelAlignment">
              <el-form-item label="是否分摊：" prop="costAllocationFlag" class="wid">
                <el-row class="m_b52">
                  <el-radio-group v-model="dataForm.costAllocationFlag" prop="costAllocationFlag">
                    <el-radio
                      v-model="dataForm.costAllocationFlag"
                      label="1"
                      checked="true"
                      name="type"
                      value="1"
                      class="mr40 radioAlignment noMarginLeft w130 t_l"
                      border
                    >是</el-radio>
                    <el-radio
                      class="mr40 radioAlignment noMarginLeft w130 t_l"
                      v-model="dataForm.costAllocationFlag"
                      label="2"
                      name="type"
                      value="2"
                      border
                    >否</el-radio>
                  </el-radio-group>
                </el-row>
                <div v-if="dataForm.costAllocationFlag == '1'" class="rates">
                  <template v-if="dataForm.costAllocationFlag == '1'">
                    <span>运营平台比例：</span>
                    <el-form-item prop="parentAllocationScale">
                      <el-input
                        clearable
                        v-model.trim="dataForm.parentAllocationScale"
                        oninput="value=value.replace(/[^\d]/g,'')"
                        maxlength="10"
                        auto-complete="off"
                        type="text"
                        :size="size"
                        class="parentPlatformRatio"
                      ></el-input>
                    </el-form-item>
                    <span class="m_r16">%</span>
                  </template>
                  <template
                    v-if="dataForm.costAllocationFlag == '1'"
                  >
                    <span>运营子平台比例：</span>
                    <el-form-item prop="childAllocationScale">
                      <el-input
                        clearable
                        v-model.trim="dataForm.childAllocationScale"
                        oninput="value=value.replace(/[^\d]/g,'')"
                        auto-complete="off"
                        maxlength="10"
                        type="text"
                        :size="size"
                        class="parentPlatformRatio"
                      ></el-input>
                    </el-form-item>
                    <span class="m_r16">%</span>
                  </template>
                  <template
                    v-if="dataForm.costAllocationFlag == '1'"
                  >
                    <span>商家比例：</span>
                    <el-form-item prop="merchantAllocationScale">
                      <el-input
                        clearable
                        v-model.trim="dataForm.merchantAllocationScale"
                        oninput="value=value.replace(/[^\d]/g,'')"
                        auto-complete="off"
                        maxlength="10"
                        type="text"
                        :size="size"
                        class="parentPlatformRatio"
                      ></el-input>
                    </el-form-item>
                      <span class="m_r16">%</span>
                  </template>
                  <template
                    v-if="dataForm.costAllocationFlag == '1'"
                  >
                    <span>店铺比例：</span>
                    <el-form-item prop="storeAllocationScale">
                      <el-input
                        clearable
                        v-model.trim="dataForm.storeAllocationScale"
                        oninput="value=value.replace(/[^\d]/g,'')"
                        maxlength="10"
                        auto-complete="off"
                        type="text"
                        :size="size"
                        class="parentPlatformRatio"
                      ></el-input>
                    </el-form-item>
                      <span>%</span>
                  </template>
                </div>
              </el-form-item>
            </el-row>
          </div>
        </div>

        <div class="w100">
          <div class="title">参与条件：</div>
          <div class="item">
            <!-- <el-row v-if="deptType == 0" class="m_b52 ways labelAlignment">
              <el-form-item label="使用渠道：" prop="channelIds" class="wid">
                <el-tree
                  :data="channelList"
                  :props="channlProps"
                  show-checkbox
                  node-key="id"
                  :default-expand-all="true"
                  ref="channelTree"
                  @check="channelIdsChange"
                ></el-tree>
              </el-form-item>
            </el-row> -->

            <el-row class="m_b52 labelAlignment">
                <el-form-item label="新老用户：" prop="selectUserType" class="wid t_r" label-width="140px">
                  <div class="flex">
                    <el-checkbox class="mr40 el-checkBox-padding noMarginLeft w130 t_l mleft10" border :indeterminate="userTypeIsIndeterminate" v-model="userTypeCheckAll" @change="handleCheckAllUserTypeChange">全选</el-checkbox>
                    <el-checkbox-group v-model="selectUserType" @change="handleCheckedUserTypeChange">
                      <el-checkbox :label="1" :key="1" class="mr40 el-checkBox-padding noMarginLeft w130 t_l" border>新用户</el-checkbox>
                      <el-checkbox :label="2" :key="2" class="el-checkBox-padding noMarginLeft w130 t_l" border>老用户</el-checkbox>
                    </el-checkbox-group>
                  </div>
                </el-form-item>
              </el-row>

             <el-row class="m_b52 labelAlignment">
              <el-form-item label="会员类型：" prop="selectMemTypes" class="wid t_r" label-width="140px">
                  <div class="flex">
                    <el-checkbox class="mr40 el-checkBox-padding noMarginLeft w130 t_l mleft10" border :indeterminate="memTypeIsIndeterminate" v-model="memTypeCheckAll" @change="handleCheckAllMemTypeChange">全选</el-checkbox>
                    <el-checkbox-group v-model="selectMemTypes" @change="handleCheckedMemTypeChange">
                      <el-checkbox :label="1" :key="1" class="mr40 el-checkBox-padding noMarginLeft" border>普通会员</el-checkbox>
                      <el-checkbox :label="2" :key="2" class="el-checkBox-padding noMarginLeft w130 t_l" border>VIP会员</el-checkbox>
                    </el-checkbox-group>
                  </div>
              </el-form-item>
            </el-row>

            <!-- <el-row class="mb10 labelAlignment">
              <el-form-item  prop="levelSelectList" class="wid errorTipsAlignment" >
                <div class="mb20 pdl50">
                    <span style="color:red">*</span>
                    <span class="color333 font16">会员等级：</span>
                  </div>
                  <div style="border:1px solid #ededed" class="ml60 pdl30 pdt20">
                <div v-for="(memberGrade,index) in memberGradeList" :key="memberGrade.deptId" class="flexBox  oh">
                  <div class="child-name mb20 oh">
                    <span class="turnInlineBlock w126 oe t_r f_l h35 lh35">{{memberGrade.childName}}</span>
                    <span class="f_l h35 lh35">：</span>
                  </div>
                  <div>
                  <el-checkbox class="mr40 el-checkBox-padding noMarginLeft w130 t_l mleft10" border :indeterminate="memberGrade.isIndeterminate" v-model="memberGrade.checkAll" @change="handleMemLevelCheckAllChange(index,memberGrade.checkAll)">全选</el-checkbox>
                  </div>
                  <div>
                  <el-checkbox-group v-model="memberGrade.levelSelectList" >
                      <el-checkbox class="mr45 mb20 el-checkBox-padding noMarginLeft w130 t_l" border @change="memLevelChange(index,memberGrade.levelList)" v-for="level in memberGrade.levelList" :checked="level.checked" v-model="level.id" :label="level.id" :key="level.key">
                        <span class="turnInlineBlock w104">  {{level.levelName.length >= 6 ? level.levelName.slice(0,5)+"..." : level.levelName}}</span>
                      </el-checkbox>
                  </el-checkbox-group>
                  </div>
                </div>
                  </div>
              </el-form-item>
            </el-row> -->

            <el-row class="m_b30 labelAlignment">
              <el-form-item label="店铺地区：" prop="storeCode" class="wid ">
                <el-radio
                  class="mr40 radioAlignment w130 t_l noMarginLeft"
                  v-model="dataForm.storeCode"
                  label="0"
                  value="0"
                  border
                >全国</el-radio>
              </el-form-item>
            </el-row>

            <el-row class="m_b30 labelAlignment">
              <el-form-item label="用户地区：" prop="userCode" class="wid ">
                <el-radio
                  class="mr40 radioAlignment w130 t_l noMarginLeft"
                  v-model="dataForm.userCode"
                  label="0"
                  value="0"
                  border
                >全国</el-radio>
              </el-form-item>
            </el-row>
            <el-row class="m_b52 labelAlignment">
                <el-form-item label="渠道：" class="wid t_r" label-width="122px"  :required="true">
                  <el-select v-model="dataForm.channelId" placeholder="请选择" size="mini" clearable class="width450">
                    <el-option
                      v-for="item in channelOption"
                      :key="item.id"
                      :label="item.channelName"
                      :value="item.id"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-row>

            <el-row>
              <el-form-item label="备注：" prop="couponUseDesc" class="wid">
                <el-input
                  clearable
                  v-model="dataForm.couponUseDesc"
                  auto-complete="off"
                  type="textarea"
                  placeholder="请输入备注"
                  :size="size"
                  class="remarks h286"
                ></el-input>
              </el-form-item>
            </el-row>
          </div>
        </div>
      </el-form>
    </div>
    <div v-show="active == 2" class="tab-container createSet active3">
      <el-tabs v-model="productStatusTabs" @tab-click="productTabs">
          <el-tab-pane :label="'生效商品('+ (Number(skuTotal) > 9999 ? '9999+' : skuTotal) +')'" name="1">
            <div class="t_r mb30">
              <!-- <el-button type="primary" plain size="mini" v-if="skuTotal<=9999">已选商品({{skuTotal}})</el-button> -->
              <!-- <el-button type="primary" plain size="mini" v-else>已选商品(9999+)</el-button> -->
            <div>
              <el-button
                  class="searchButton"
                  size="mini"
                  @click="searchGoodsFlag = !searchGoodsFlag"
                  icon="el-icon-search"
                >搜索</el-button>
              <el-button class="searchButton" @click="saveAllGoods">添加全部商品</el-button>
              <el-button class="searchButton" @click="add">添加商品</el-button>
              <el-button class="resetButton" @click="batchDeleteProduct">批量删除</el-button>
            </div>
          </div>
          <el-row>
              <el-form :inline="true" :model="queryGoodsReuqest" ref="queryGoodsReuqest" class="rightForm demo-form-inline2" size="small">
                <span v-if="searchGoodsFlag">
                  <el-form-item label="店铺：" prop="storeId" class="mb30">
                    <template>
                      <el-select v-model="queryGoodsReuqest.storeId" clearable placeholder="全部">
                        <el-option
                          v-for="item in storeTableData"
                          :key="item.id"
                          :label="item.storeName"
                          :value="item.id"
                        ></el-option>
                      </el-select>
                    </template>
                  </el-form-item>

                  <el-form-item label="商品编码：" prop="goodsCode" class="mb30">
                    <el-input v-model="queryGoodsReuqest.goodsCode" clearable placeholder="商品编码" maxlength="80"></el-input>
                  </el-form-item>
                  <el-form-item label="商品名称：" prop="goodsName" class="mb30">
                    <el-input v-model="queryGoodsReuqest.goodsName" clearable placeholder="商品名称" maxlength="80"></el-input>
                  </el-form-item>
                  <el-form-item label="商品分类：" prop="goodsType" class="mb30">
                    <el-input v-model="queryGoodsReuqest.goodsType" clearable placeholder="商品分类" maxlength="80"></el-input>
                  </el-form-item>
                  <el-form-item label >
                    <el-button
                      class="resetButton"
                      size="mini"
                      @click="resetStaticGoodsSearch()"
                    >重置</el-button>
                    <el-button class="resetButton" size="mini" @click="skillQueryGoods()">查询</el-button>

                  </el-form-item>
                </span>
                <!-- <el-form-item>
                  <el-button
                    type="primary"
                    size="mini"
                    @click="searchGoodsFlag = !searchGoodsFlag"
                    icon="el-icon-search"
                  >搜索</el-button>
                </el-form-item> -->
              </el-form>
          </el-row>
          <div class="tableTree">

            <!-- <el-table
              :data="productTableData"
              :header-cell-style="tableHeaderColor"
              ref="multipleTable"
              style="width: 100%"
              :row-class-name="tableRowClassName"
              border
              default-expand-all
              row-key="goodsId"
              :size="size"
              :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
              @selection-change="selectPorduct"
              class="tableStyle"
            > -->
            <el-table :data="productTableData"  row-key="id" default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                        @selection-change="selectPorduct" style="width: 100%" class="tableStyle">
              <el-table-column align="left" width="30">
                <template slot="header" slot-scope="scope">
                  <div class="isAllChecked" v-if="productTableData.length > 0">
                    <el-checkbox
                      :indeterminate="isIndeterminateProductCheck"
                      v-model="isAllProductChecked"
                      @change="handleCheckedAllProductChange"
                    ></el-checkbox>
                  </div>
                </template>
              </el-table-column>
               <el-table-column width="40">
                  <template slot-scope="scope">
                    <el-checkbox
                      :indeterminate="scope.row.isIndeterminateCheck"
                      v-model="scope.row.isCheck"
                      @change="handleCheckedProductChange(scope.row,$event)"

                    ></el-checkbox>
                  </template>
                </el-table-column>
              <el-table-column prop="goodsCode" label="商品编码" sortable align="left"></el-table-column>
              <el-table-column prop="goodsName" label="商品名称" align="center"></el-table-column>
              <!-- <el-table-column prop="merchantName" label="商家名称" align="center"></el-table-column> -->
              <el-table-column prop="goodsType" label="商品分类" align="center"></el-table-column>
              <el-table-column prop="reserveNum" label="库存" align="center"></el-table-column>
              <el-table-column prop="storeName" label="所属店铺" align="center"></el-table-column>
              <el-table-column prop="price" label="原价（元）" align="center"></el-table-column>
              <el-table-column label="操作" fixed="right" align="center">
                <template slot-scope="scope">
                  <el-button
                    :size="size"
                    type="text"
                    @click="deleteProduct(scope.$index, scope.row)"
                  >删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>

          <div v-if="productTableData.length > 0" class="t_r">
            <el-pagination
              @size-change="goodsSizeChange"
              @current-change="goodsCurrentChange"
              :current-page="goodsStaticDataForm.start"
              :page-sizes="[10]"
              :page-size="goodsStaticDataForm.limit"
              layout="total, sizes, prev, pager, next, jumper"
              :total="goodsTotal"
            ></el-pagination>
          </div>
        </el-tab-pane>
        <el-tab-pane :label="'互斥商品('+ (Number(mutexMerchantProductTotalCount) > 9999 ? '9999+' : mutexMerchantProductTotalCount) +')'" name="2">
              <div class="row-line-button t_r">
                <div style="width:100%">
                  <!-- <el-button type="primary" size="mini" @click="addAllProduct">全部添加</el-button> -->
                  <!-- <el-button type="primary" size="mini" @click="add">添加促销商品</el-button> -->
                  <el-button class="searchButton"  @click="batchRenewAdd">批量重新添加</el-button>
                </div>
              </div>
              <div class="tableTree">

                <el-table :data="mutexProductList"  row-key="goodsId" default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                  @selection-change="batchRenewAddSelectionChange" style="width: 100%" class="tableStyle">
                  <el-table-column align="left" width="30">
                    <template slot="header" slot-scope="scope">
                      <div class="isAllChecked" v-if="mutexProductList.length > 0">
                        <el-checkbox
                          :indeterminate="isIndeterminateCheck"
                          v-model="isAllChecked"
                          @change="handleCheckedAllChange"
                        ></el-checkbox>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column width="40">
                    <template slot-scope="scope">
                      <el-checkbox
                        :indeterminate="scope.row.isIndeterminateCheck"
                        v-model="scope.row.isCheck"
                        @change="handleCheckedChange(scope.row,$event)"
                      ></el-checkbox>
                    </template>
                  </el-table-column>
                  <el-table-column prop="goodsCode" label="商品编码" sortable align="left" width="200"></el-table-column>
                  <el-table-column prop="goodsName" label="商品名称" align="center" width="200"></el-table-column>
                  <el-table-column prop="goodsType" label="商品分类" align="center" width="200"></el-table-column>
                  <el-table-column prop="reserveNum" label="库存" align="center" width="200"></el-table-column>
                  <el-table-column prop="storeName" label="所属店铺" width="200"></el-table-column>
                  <el-table-column prop="price" label="原价（元）" align="center" width="200"></el-table-column>
                  <el-table-column align="center" fixed="right" label="操作" width="390">
                    <template slot-scope="scope">
                      <el-button @click="getMutexInfo(scope.row)" v-if="scope.row.spuId != '0'" type="text" class="textButton" size="small">查看详情</el-button>
                      <el-button @click="renewAdd(scope.row)" type="text" class="textButton" size="small">重新添加</el-button>
                    </template>
                  </el-table-column>
                </el-table>
                <div class="toolbar t_r" >
                  <el-pagination
                    @size-change="handleSizeChangeMutexProductList"
                    @current-change="handleCurrentChangeMutexProductList"
                    :current-page="mutexProductForm.start"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="mutexProductForm.limit"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="mutexProductTotal"
                  >
                  </el-pagination>
                </div>
              </div>
          </el-tab-pane>
      </el-tabs>
    </div>

    <div v-show="active == 3" class="content createSet activeTrigger">
      <div>
        <el-form
          :inline="true"
          :model="triggerSceneForm"
          :rules="triggerSceneFormRules"
          ref="triggerSceneForm"
          class="t_l"
        >
          <el-form-item label="页面发放：" class="trigger labelTextColor333 mb30 " >
            <el-checkbox v-model="triggerSceneForm.pageTrigger" border class="el-checkBox-padding noMarginLeft">用户领取</el-checkbox>
          </el-form-item>
          <el-form-item label="系统发放：" class="trigger labelTextColor333 mb30" >
            <el-checkbox v-model="triggerSceneForm.userRegistered" class="mr40 el-checkBox-padding noMarginLeft" border>注册</el-checkbox>
            <el-checkbox v-model="triggerSceneForm.userDetail" class="el-checkBox-padding noMarginLeft" border>完善个人信息</el-checkbox>
          </el-form-item>
          <el-form-item label="任务发放：" class="trigger labelTextColor333 mb30 ">
            <el-checkbox v-model="triggerSceneForm.sign" class="mr40 el-checkBox-padding noMarginLeft" border>签到</el-checkbox>
            <el-checkbox v-model="triggerSceneForm.favorite" class=" el-checkBox-padding noMarginLeft" border>收藏店铺</el-checkbox>
            <!-- <el-checkbox v-model="triggerSceneForm.lottery">抽奖</el-checkbox> -->
          </el-form-item>
          <el-form-item label="发放次数：" class="trigger labelTextColor333 mb30">
            <div class="flex issueTime">
              <el-input clearable v-model="triggerSceneForm.triggerNum" :size="size" maxlength="10"></el-input>
              <span class="s1">次</span>
            </div>
          </el-form-item>

          <div  class="triggerTable w100">
            <div class="flexBox">
              <span class="font16 color333 titleText pdt8">活动发放：</span>
              <div class="w100">
              <div class="flex w100">
                <el-tabs v-model="triggerActiveName" @tab-click="triggerActiveClick">
                  <el-tab-pane label="拼团" name="1"></el-tab-pane>
                  <el-tab-pane label="秒杀" name="2"></el-tab-pane>
                </el-tabs>
              </div>
              <div class="mb30 w100 t_r">
                <el-button class="searchButton" :size="size" @click="addTrigger">添加</el-button>
              </div>
              <div class="table-section " v-if="triggerActiveName == '1'">
                <el-table
                  :data="patchGrouponTableData"
                  :header-cell-style="{ 'color': '#FFF','background-color': '#409EFF','text-align': 'center'}"
                  :highlight-current-row="true"
                  :max-height="1500"
                  :size="size"
                >
                  <el-table-column prop="id" label="ID"  align="center" width="100"></el-table-column>
                  <el-table-column prop="promName" label="活动名称" align="center" width="200"></el-table-column>
                  <el-table-column label="活动开始/结束时间" align="center" width="300">
                    <template slot-scope="scope">{{scope.row.startTime}} - {{scope.row.endTime}}</template>
                  </el-table-column>
                  <el-table-column label="操作" align="center" >
                    <template slot-scope="scope">
                      <el-button
                        :size="size"
                        type="text"
                        @click="deleteTrigger(scope.$index, scope.row)"
                      >删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <div class="table-section " v-if="triggerActiveName == '2'">
                <el-table
                  :data="skillTableData"
                  :header-cell-style="{ 'color': '#FFF','background-color': '#409EFF','text-align': 'center'}"
                  :highlight-current-row="true"
                  :max-height="1500"
                  :size="size"
                >
                  <el-table-column
                    prop="id"
                    label="ID"
                    align="center"
                    width="100"
                  ></el-table-column>
                  <el-table-column prop="promName" label="活动名称" align="center" width="200"></el-table-column>
                  <el-table-column label="活动开始/结束时间" align="center" width="300">
                    <template slot-scope="scope">{{scope.row.startTime}} - {{scope.row.endTime}}</template>
                  </el-table-column>
                  <el-table-column label="操作" align="center" >
                    <template slot-scope="scope">
                      <el-button
                        :size="size"
                        type="text"
                        @click="deleteTrigger(scope.$index, scope.row)"
                      >删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </div>
            </div>
          </div>
        </el-form>
      </div>
    </div>

    <div v-if="active == 4" class="tab-container tab-success createSet">
      <div class="titleInfo">
        <img src="/static/images/success.png" />
        <span class="font20">活动创建成功!</span>
      </div>
      <div class="step-button2">
        <el-button type="primary" plain @click="viewList" class="resetButton">查看红包列表</el-button>
        <template>
          <kt-button
            type="primary"
             class="searchButton"
            :size="size"
            @click="shenheHuodong(0)"
            perms="market:seckill:submit"
            v-show="[11,14].includes(statusFormat(dataForm))"
            label="提交审核"
          />

          <kt-button
            type="primary"
            :size="size"
            class="searchButton"
            @click="shenheHuodong(1)"
            v-show="statusFormat(dataForm) == 12"
            perms="market:seckill:verify"
            label="审核"
          />
        </template>
        <kt-button
          type="primary"
          :size="size"
          class="resetButton"
          @click="templateDialogFormVisible = true"
          perms="market:coupon:addtemp"
          label="保存模板"
        />
      </div>
    </div>

    <div class="step-button" v-if="active < 5">
      <el-button
        type="primary"
        :plain="active != 1 && active != 5"
        :size="size"
        v-if="active != 1 && active != 5"
        @click="back"
        class="cancelButton"
      >上一步</el-button>
      <el-button type="primary" v-if="active != 5" :size="size" @click="next" class="searchButton">下一步</el-button>
    </div>

    <!-- 模板弹窗 -->
    <el-dialog title="保存模板" :visible.sync="templateDialogFormVisible" class="el-dialog-style" :close-on-click-modal="false">
      <el-form :model="templateForm" label-width="130px">
        <el-form-item label="模板名称：">
          <el-input clearable v-model="templateForm.templateName" autocomplete="off" size="mini" maxlength="80"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" plain @click="templateDialogFormVisible=false" size="mini" class="cancelButton">取消</el-button>
        <el-button type="primary" @click="saveTemplate()" size="mini" class="searchButton">保存模板</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt />
    </el-dialog>

    <el-dialog :visible.sync="dialogVisibleTwo" title="添加商品" :close-on-click-modal="false">
      <div class="flex">
        <el-form :inline="true" class="demo-form-inline2" size="small" v-model="formInline" ref="formInline" label-width="112px">
          <el-form-item label="商品名称：" class="w178 mb30">
            <el-input clearable v-model="formInline.goodsName" placeholder="商品名称" maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="商品编码：" prop="thirdSpuId" class="w178 mb30">
                <el-input v-model="formInline.thirdSpuId" auto-complete="off" clearable maxlength="80" placeholder="商品编码"></el-input>
              </el-form-item>
          <el-form-item label="商品分类：" class="w178 mb30">
            <el-input clearable v-model="formInline.goodsCategory" placeholder="商品分类" maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="所属店铺名称：" prop="storeName" class="w178 mb30">
            <el-input v-model="formInline.storeName" auto-complete="off" clearable maxlength="80" placeholder="所属店铺名称"></el-input>
          </el-form-item>
        </el-form>
      </div>

        <el-row class="t_r mb30">
          <el-button  @click="restProductForm" class="resetButton" icon="el-icon-refresh">重置</el-button>
          <el-button  icon="el-icon-search" @click="queryPageProductManagement" class="searchButton">搜索</el-button>

        </el-row>
      <div class="table-section">
        <el-table
          :data="tableDataTwo"
          v-loading="productListloading"
          :header-cell-style="tableHeaderColor"
          ref="multipleTable"
          :row-class-name="tableRowClassName"
          :size="size"
          @selection-change="selectAddProductChange"
        >
           <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column prop="thirdSpuId" label="商品编码" sortable align="center"></el-table-column>
          <el-table-column prop="goodsName" label="商品名称" align="center"></el-table-column>
          <el-table-column prop="goodsCategory" label="商品分类" align="center"></el-table-column>
          <el-table-column prop="storeName" label="所属店铺" align="center"></el-table-column>
          <el-table-column prop="salePriceScope" label="原价（元）" align="center"></el-table-column>
        </el-table>
      </div>

      <div class="chosenSelect">
        <span>已选择商品：{{selectAddProduct.length}}</span>
        <div v-if="tableDataTwo.length > 0" class="t_r">
          <el-pagination
            @size-change="producthandleSizeChange"
            @current-change="producthandleCurrentChange"
            :current-page="formInline.start"
            :page-sizes="[10]"
            :page-size="formInline.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="productListTotal"
          ></el-pagination>
        </div>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" plain @click="dialogVisibleTwo=false" size="mini" class="cancelButton">取消</el-button>
        <el-button type="primary" @click="addProductChange" size="mini" class="searchButton">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="审核" class="el-dialog-style" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
       <el-form :model="form" ref="form" :rules="formRules">
        <el-form-item class="textarea" prop="checkRemark">
          <el-input
            clearable
            v-model="form.checkRemark"
            autocomplete="off"
            placeholder="请输入审核意见"
            type="textarea"
            rows="6"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" plain @click="reviewDialog(4)" size="mini" class="cancelButton">不通过</el-button>
        <el-button type="primary" @click="reviewDialog(11)" size="mini" class="searchButton">通过</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogVisibleMerchant" title="添加商家" :close-on-click-modal="false">
      <div class="flex">
        <el-form :inline="true" class="demo-form-inline2" size="small" v-model="merchantDataForm" ref="merchantDataForm">
          <el-form-item label="商家名称：" class="w178">
            <el-input clearable v-model="merchantDataForm.name" placeholder="商家名称" maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="商家编码：" class="w178">
            <el-input clearable v-model="merchantDataForm.orgNumber" placeholder="商家编码" maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="商家类型：" prop="merchantType" class="w178 mb30">
            <el-select v-model="merchantDataForm.merchantType" placeholder="全部" clearable>
              <el-option label="自营商家" value="1"></el-option>
              <el-option label="第三方商户" value="2"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <el-row class="t_r mb30 w100">
          <el-button class="resetButton" icon="el-icon-refresh" @click="restMerchantForm" >重置</el-button>
          <el-button class="searchButton" icon="el-icon-search" @click="queryPageMerchantManagement">搜索</el-button>
        </el-row>
      </div>
      <div class="table-section">
        <el-table
          :data="merchantTableData"
          v-loading="productListloading"
          :header-cell-style="tableHeaderColor"
          ref="multipleTable"
          :row-class-name="tableRowClassName"
          :size="size"
          @selection-change="addMerchantChangeSelect"
        >
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column prop="orgNumber" label="商家编码" sortable align="center"></el-table-column>
          <el-table-column prop="name" label="商家名称" align="center"></el-table-column>
          <el-table-column prop="merchantType" label="商家类型" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.merchantType == '1'">自营商家</span>
              <span v-else-if="scope.row.merchantType == '2'">第三方商家</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="chosenSelect">
        <span>已选择商家：{{addMerchantSelect.length}}</span>
        <div v-if="merchantTableData.length > 0" class="t_r">
          <el-pagination
            @size-change="merchanthandleSizeChange"
            @current-change="merchanthandleCurrentChange"
            :current-page="merchantDataForm.start"
            :page-sizes="[10]"
            :page-size="merchantDataForm.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="merchantListTotal"
          ></el-pagination>
        </div>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" plain @click="dialogVisibleMerchant=false" size="mini" class="cancelButton">取消</el-button>
        <el-button type="primary" @click="addMerchantChange" size="mini" class="searchButton">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogVisibleStore" title="添加店铺" :close-on-click-modal="false">
      <el-row class="search-button-fix t_r">
        <el-form :inline="true" class="demo-form-inline2" size="small" v-model="storeDataForm" ref="storeDataForm">
          <el-form-item label="店铺名称：" class="w178 mb30">
            <el-input clearable v-model="storeDataForm.storeName" placeholder="店铺名称" maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="店铺编码：" class="w178">
            <el-input clearable v-model="storeDataForm.storeCode" placeholder="店铺编码" maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="所属商家名称：" prop="merchantName" class="w178">
          <el-input v-model="storeDataForm.merchantName" maxlength="80" placeholder="所属商家名称" size="mini" clearable></el-input>
        </el-form-item>
        <el-form-item label="店铺类型：" prop="storeType" class="w178 mb30">
          <el-select v-model="storeDataForm.storeType" placeholder="全部" size="mini" clearable>
            <el-option label="自营店铺" value="0"></el-option>
            <el-option label="入驻店铺" value="1"></el-option>
          </el-select>
        </el-form-item>
        </el-form>
        <el-row class="t_r mb30">
          <el-button
            class="resetButton"
            icon="el-icon-refresh"
            @click="restStoreForm('storeDataForm')"
          >重置</el-button>
          <el-button class="searchButton" icon="el-icon-search" @click="queryPageStoreList">搜索</el-button>

        </el-row>
      </el-row>
      <div class="table-section">
        <el-table
          :data="storeAddTableData"
          v-loading="productListloading"
          :header-cell-style="tableHeaderColor"
          ref="multipleTable"
          :row-class-name="tableRowClassName"
          :size="size"
          @selection-change="addStoreChangeSelect"
        >
          <!-- <el-table-column prop="pictureUrl" label="主图" showImg="true"  align="center">
							<template slot-scope="scope">
							  　<img :src="scope.row.pictureUrl" width="30" height="30"/>
							</template>
          </el-table-column>-->
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column prop="storeCode" label="店铺编码" sortable align="center" width="320"></el-table-column>
          <el-table-column prop="storeName" label="店铺名称" align="center"></el-table-column>
          <el-table-column label="店铺类型" align="center">
            <template slot-scope="scope">
							  　{{scope.row.storeType == '0' ? '自营店铺' : '入驻店铺'}}
							</template>
          </el-table-column>
          <el-table-column prop="merchantName" label="所属商家" align="center"></el-table-column>
        </el-table>
      </div>
      <div class="chosenSelect">
        <span>已选择店铺：{{addStoreSelect.length}}</span>
        <div v-if="storeAddTableData.length > 0" class="t_r">
          <el-pagination
            @size-change="storehandleSizeChange"
            @current-change="storehandleCurrentChange"
            :current-page="storeDataForm.start"
            :page-sizes="[10]"
            :page-size="storeDataForm.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="storeListTotal"
          ></el-pagination>
        </div>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" plain @click="dialogVisibleStore=false" size="mini">取消</el-button>
        <el-button type="primary" @click="addStoreChange" size="mini">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="triggerVisible" title="添加活动" :close-on-click-modal="false">
      <div class="flex">
        <el-form :inline="true" size="small" :model="triggerDataForm" ref="triggerDataForm" :rules="triggerDataFormRules">
          <el-form-item label="ID：" prop="id" v-if="triggerActiveName == '1'">
            <el-input
              clearable
              v-model="triggerDataForm.id"
              placeholder="ID"
            ></el-input>
          </el-form-item>
          <el-form-item label="ID：" prop="promotionId" v-if="triggerActiveName == '2'">
            <el-input
              clearable
              v-model="triggerDataForm.promotionId"
              placeholder="ID"
              maxlength="80"
            ></el-input>
          </el-form-item>
          <el-form-item label="名称：" prop="promName">
            <el-input clearable v-model="triggerDataForm.promName" placeholder="名称" maxlength="80"></el-input>
          </el-form-item>

          <el-row class="mb30 t_r">
            <el-form-item>
              <el-button  @click="restForm()" class="resetButton" icon="el-icon-refresh">重置</el-button>
              <el-button
                icon="el-icon-search"
                @click="triggerhandleCurrentChange(1)"
                class="searchButton"
              >搜索</el-button>

            </el-form-item>
          </el-row>
        </el-form>
      </div>
      <div class="table-section">
        <el-table
          :data="triggerAddTableData"
          v-loading="productListloading"
          :header-cell-style="tableHeaderColor"
          ref="multipleTable"
          :row-class-name="tableRowClassName"
          :size="size"
          @selection-change="addTriggerChangeSelect"
        >
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column
            prop="id"
            label="活动ID"
            sortable
            align="center"
            width="200"
          ></el-table-column>
          <el-table-column prop="promName" label="活动名称" align="center" width="200"></el-table-column>
          <el-table-column label="活动开始/结束时z间" align="center">
            <template slot-scope="scope">{{scope.row.startTime}} - {{scope.row.endTime}}</template>
          </el-table-column>
        </el-table>
      </div>
      <div class="chosenSelect">
        <span>已选择数量:{{triggerSelectData.length}}</span>
        <div v-if="triggerAddTableData.length > 0" class="t_r">
          <el-pagination
            @size-change="triggerhandleSizeChange"
            @current-change="triggerhandleCurrentChange"
            :current-page="triggerDataForm.start"
            :page-sizes="[10]"
            :page-size="triggerDataForm.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="triggerListTotal"
          ></el-pagination>
        </div>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" plain @click="triggerVisible=false" size="mini" class="cancelButton">取消</el-button>
        <el-button type="primary" @click="addTriggerChange" size="mini" class="searchButton">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="添加标签" :visible.sync="addTagDialogFormVisible" class="el-dialog-style" :close-on-click-modal="false">
      <el-form :model="addTagForm" :rules="addTagRules" ref="addTagForm">
        <el-form-item label="标签分类：" label-width="130px" prop="categoryId" class="mb30">
          <el-select v-model="addTagForm.categoryId" placeholder="请选择分类标签" size="mini">
            <el-option
              v-for="(item, index) in tagCategoryList"
              :key="index"
              :label="item.categoryName"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="标签名称：" label-width="130px" prop="tagName">
          <el-input clearable placeholder="请输入标签名称" v-model.trim="addTagForm.tagName" size="mini" maxlength="30"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" plain @click="addTagDialogFormVisible=false" size="mini" class="cancelButton">取消</el-button>
        <el-button type="primary" @click="addNewTag" size="mini" class="searchButton">确定</el-button>
      </div>
    </el-dialog>

    <!-- 互斥活动详情 -->
    <el-dialog :visible.sync="mutexPromotionVisible" title="互斥活动详情" width="70%" :close-on-click-modal="false">
      <div>
        <el-table :data="mutexPromotionList" ref="multipleTable" :row-class-name="tableRowClassName"  :size="size">
          <el-table-column prop="promotionId" width="280" label="互斥活动编码" sortable align="center"></el-table-column>
          <el-table-column prop="promName"  width="150" label="互斥活动名称" align="center">
            <template slot-scope="scope">
              <el-button @click="linkInfoByMutexProduct(scope.row.promotionId)" type="text" class="textButton" size="small">{{scope.row.promName}}</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="goodsCategory"  width="360" label="互斥活动时间" align="center">
            <template slot-scope="scope">
                <span>{{scope.row.startTime}} - {{scope.row.endTime}}</span>
              </template>
          </el-table-column>
          <el-table-column prop="storeName" label="活动状态" align="center">
            <template slot-scope="scope">
              <span class="color333 font18" v-if="scope.row.status == 0">待提交</span>
              <span class="color333 font18" v-if="scope.row.status == 9">活动草稿</span>
              <span class="color333 font18" v-else-if="statusFormat(scope.row) == 11">待提交</span>
              <span class="color333 font18" v-else-if="statusFormat(scope.row) == 12">待审核</span>
              <span class="color333 font18" v-else-if="statusFormat(scope.row) == 13">未开始</span>
              <span class="color333 font18" v-else-if="statusFormat(scope.row) == 14">审核未通过</span>
              <span class="color333 font18" v-else-if="statusFormat(scope.row) == 15">进行中</span>
              <span class="color333 font18" v-else-if="statusFormat(scope.row) == 16">已过期</span>
              <span class="color333 font18" v-else-if="statusFormat(scope.row) == 17">已结束</span>
              <span class="color333 font18" v-else-if="scope.row.status == 7">已关闭</span>
            </template>
          </el-table-column>
          <el-table-column prop="creatorName" label="创建人" align="center"></el-table-column>
          <el-table-column prop="deptName"  label="创建组织" align="center"></el-table-column>
        </el-table>
        <!--分页栏-->
        <div class="toolbar t_r">
          <el-pagination
            @size-change="mutexPromotionListSizeChange"
            @current-change="mutexPromotionListCurrentChange"
            :current-page="mutexPromotionForm.start"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="mutexPromotionForm.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="mutexPromotionListTotal"
          ></el-pagination>
        </div>
      </div>
      <div slot="footer" class="dialog-footer t_c">
        <el-button  :size="size" @click.native="mutexPromotionVisible = false" class="searchButton">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { formatDate } from "@/utils/datetime";
import KtButton from "@/views/Core/KtButton";
import {
  singleFrontPromTypesRadio,
  chanelCodesRadio,
  proPlatformRadio,
  proUserTypeRadio,
  proMemberTypeRadio,
  proMemberLevelRadio
} from "@/market/dict/marketDict";

import { getAllRow, changeChild, changeParent } from "@/assets/js/tableTree.js";

export default {
  components: {
    KtButton
  },
  props: {
    type: {
      type: String,
      default: "0"
    },
    temId: {
      type: String,
      default: "0"
    }
  },
  data() {
    let this_  = this;

      var isNumber = (rule, value, callback) => {
        if (value === "") {
          return callback();
        } //这是用来判断如果不是必须输入的，则直接跳出
        const r = /^\+?[1-9][0-9]*$/; // 正整数
        // 如果判断不符合正则，则不是正整数不能提交
        if (!r.test(value)) {
          return callback(new Error("必须为正整数"));
        } else {
          // if (
          //   this.filters.parentAllocationScale != undefined &&
          //   this.filters.childAllocationScale != undefined &&
          //   this.filters.merchantAllocationScale != undefined &&
          //   this.filters.storeAllocationScale != undefined
          // ) {
          let countScale =
            Number(this_.dataForm.parentAllocationScale | 0) +
            Number(this_.dataForm.childAllocationScale | 0) +
            Number(this_.dataForm.merchantAllocationScale | 0) +
            Number(this_.dataForm.storeAllocationScale | 0);
          if (countScale != 100) {
            return callback(new Error("加起来必须等于100%"));
          } else {
            this_.$refs.dataForm.clearValidate("childAllocationScale");
            this_.$refs.dataForm.clearValidate("merchantAllocationScale");
            this_.$refs.dataForm.clearValidate("storeAllocationScale");
            this_.$refs.dataForm.clearValidate("parentAllocationScale");
            return callback();
          }
          // }
          // return callback();
        }
      };
    var checkParentAllocationScale = (rule, value, callback) => {
      if (!value) {
        callback(new Error("请输入母平台分摊比例"));
      } else if (!/^[1-9][0-9]*([.][0-9]{1,2})?$/.test(value)) {
        //分摊比例为整数或两位小数
        callback(new Error("母平台分摊比例格式错误"));
      } else {
        callback();
      }
    };
    var checkChildAllocationScale = (rule, value, callback) => {
      if (!value) {
        callback(new Error("请输入子平台分摊比例"));
      } else if (!/^[1-9][0-9]*([.][0-9]{1,2})?$/.test(value)) {
        //分摊比例为整数或两位小数
        callback(new Error("子平台分摊比例格式错误"));
      } else {
        callback();
      }
    };
    var checkMerchantAllocationScale = (rule, value, callback) => {
      if (!value) {
        callback(new Error("请输入商家分摊比例"));
      } else if (!/^[1-9][0-9]*([.][0-9]{1,2})?$/.test(value)) {
        //分摊比例为整数或两位小数
        callback(new Error("商家分摊比例格式错误"));
      } else {
        callback();
      }
    };
    var checkStoreAllocationScale = (rule, value, callback) => {
      if (!value) {
        callback(new Error("请输入店铺分摊比例"));
      } else if (!/^[1-9][0-9]*([.][0-9]{1,2})?$/.test(value)) {
        //分摊比例为整数或两位小数
        callback(new Error("店铺分摊比例格式错误"));
      } else {
        callback();
      }
    };
    var checkAmount = (rule, value, callback) => {
      var r = /^\d+\.?\d{0,2}$/; // 2位小数
      // 如果判断不符合正则，则不是正整数不能提交
      if (!r.test(value)) {
        return callback(new Error("请输入数字(支持2位小数)"));
      }
      return callback();
    };
    var checkPositiveInteger = (rule, value, callback) => {
      var r1 = /^\+?[1-9][0-9]*$/; // 正整数
      if (!value) {
        return callback();
      } else if (!r1.test(value)) {
        return callback(new Error("必须为正整数"));
      }
      return callback();
    };

    var checkNumber = (rule, value, callback) => {
      if (value === "") {
        return callback();
      }
      const r = /^\+?[1-9][0-9]*$/; // 正整数
      if (!r.test(value)) {
        return callback(new Error("请输入数字"));
      }
      return callback();
    };
    /**
       * 校验会员等级
       */
      var checkMemLevel = (rule, value, callback) => {
        //查看每个子平台是否都选中了
        let memberGradeList = this.memberGradeList;
        if(memberGradeList == null || memberGradeList.length < 1){
           return callback(new Error("会员等级不能为空"));
        }
        let flag = false;
        for(var i = 0; i< memberGradeList.length ; i++){
          if((memberGradeList[i].levelSelectList == null || memberGradeList[i].levelSelectList.length < 1 )&& !memberGradeList[i].checkAll){
            flag = true;
            break;
          }
        }
        if(flag){
              return callback(new Error("每个平台必须选中一个会员等级"));
        }
        return callback();
      };

      /**
       * 会员类型
       */
      var checkMemType = (rule, value, callback) => {
        if(this.selectMemTypes == null || this.selectMemTypes.length < 1){
          return callback(new Error("请选择会员类型"));
        }

        return callback();

      };

       /**
       * 新老用户
       */
      var checkUserType = (rule, value, callback) => {
        if(this.selectUserType == null || this.selectUserType.length < 1){
          return callback(new Error("请选择新老用户"));
        }

        return callback();
      };

    return {
      channelOption:[],
      promotionMethod: true,
      discountMethod: false,
      // 活动时间校验
      timeCheck: {
        disabledDate: time => {
          if (this.promotionStartEndTime) {
            return (
              time.getTime() < Date.now() - 8.64e7 ||
              time.getTime() > new Date(this.promotionStartEndTime).getTime()
            );
          } else {
            return time.getTime() < Date.now() - 8.64e7;
          }
        }
      },
      templateDialogFormVisible: false, //模板弹窗
      templateForm: {}, //模板model
      formLabelWidth: "120px",
      dialogFormVisible: false,
      form: {},
      row: {},
      templateId: 0,
      couponId: "0",
      proActiveName: "first",
      shenhe: 0,
      productListloading: true,
      selectedOptions: [],
      formInline: {
        goodsName: null,
        goodsCategory: null,
        code: null,
        storeName: null,
        start: 1,
        limit: 10
      },
      tabsIndex: "first",
      tableData: [],
      tableDataTwo: [],
      dialogImageUrl: "",
      dialogVisible: false,
      dialogVisibleTwo: false,
      size: "mini",
      active: 0,
      isIndeterminate2: true,
      proUserTypeRadios: proUserTypeRadio,
      checkAll2: true,
      dataForm: {
        costAllocationFlag: "1", //是否分摊
        storeCode: "0", //店铺区域
        userCode: "0", //用户区域
        couponType: "0", //红包类型
        amountDeductType: "0", //金额抵扣类型
        couponMode: "0", //优惠方式
        limitOfAction: "0", //作用限制
        overlayFlag: "1", //是否叠加
        channelIds: [1, 2, 3], //渠道Ids
        promName: "",
        couponAmount: null,
        couponUseDesc: "",
        // grantType:"0",
        idLimitNum: 1,
        idLimitDayNum: 1,
        proUserType: "0",
        costAllocation: "",
        proportion: "",
        grantTotalNum: null,
        activityStartTime: "",
        activityEndTime: "",
        couponUseTime: [],
        couponUseStartTime: "",
        couponUseEndTime: "",
        useTotalAmountLimit: "",
        activityTime: [],
        grantType: "0",
        useChannel: [],
        frontPromType: "1200",
        promType: "12",
        parcelsFlag: "-1"
      },
      dataFormRules: {
        costAllocationFlag: [
          {
            required: true,
            message: "请选择是否分摊",
            trigger: "change"
          }
        ],
        parentAllocationScale: [
          {
            required: true,
            validator: isNumber,
            trigger: "blur"
          },
          {
            required: true,
            validator: isNumber,
            trigger: "change"
          }
        ],
        childAllocationScale: [
          {
            required: true,
            validator: isNumber,
            trigger: "blur"
          },
          {
            required: true,
            validator: isNumber,
            trigger: "change"
          }
        ],
        merchantAllocationScale: [
          {
            required: true,
            validator: isNumber,
            trigger: "blur"
          },
          {
            required: true,
            validator: isNumber,
            trigger: "change"
          }
        ],
        storeAllocationScale: [
          {
            required: true,
            validator: isNumber,
            trigger: "blur"
          },
          {
            required: true,
            validator: isNumber,
            trigger: "change"
          }
        ],
        channelIds: [
          { required: true, message: "请选择使用渠道", trigger: "checked" }
        ],
        storeCode: [
          { required: true, message: "请选择店铺区域", trigger: "change" }
        ],
        userCode: [
          { required: true, message: "请选择用户区域", trigger: "change" }
        ],
        limitOfAction: [
          { required: true, message: "请选择作用限制", trigger: "change" }
        ],
        overlayFlag: [
          { required: true, message: "请选择是否叠加", trigger: "change" }
        ],
        promName: [
          { required: true, message: "请输入红包名称", trigger: "blur" },
          { min: 3, max: 60, message: "长度在 3 到 60 个字符", trigger: "blur" }
        ],
        couponType: [
          { required: true, message: "请输入红包种类", trigger: "blur" }
        ],
        amountDeductType: [
          { required: true, message: "请输入金额抵扣类型", trigger: "blur" }
        ],
        couponMode: [
          { required: true, message: "请输入优惠方式", trigger: "blur" }
        ],
        couponAmount: [
          { required: true, validator: checkAmount, trigger: "blur" }
        ],
        grantTotalNum: [{ validator: checkPositiveInteger, trigger: "blur" }],
        idLimitNum: [{ validator: checkPositiveInteger, trigger: "blur" }],
        idLimitDayNum: [{ validator: checkPositiveInteger, trigger: "blur" }],
        activityTime: [
          { required: true, message: "请输入券活动日期", trigger: "blur" }
        ],
        couponUseDesc: [
          { required: false, message: "请输入使用说明", trigger: "blur" }
        ],
        couponUseTime: [
          { required: true, message: "请输入使用时间设置", trigger: "blur" }
        ],
        useTotalAmountLimit: [
          { required: true, validator: checkAmount, trigger: "blur" }
        ],
        costAllocation: [
          { required: true, message: "请选择是否成本分摊", trigger: "change" }
        ],
        // levelSelectList: [{ required: true , validator: checkMemLevel, trigger: "blur"}] ,
        selectMemTypes: [{required: true, validator: checkMemType , trigger: "blur"}],
        selectUserType: [{ required: true, validator: checkUserType, trigger: "change" }],

      },
      triggerDataFormRules:{
        id: [
          { validator: checkNumber,trigger:"blur" },
        ]
      },

      //渠道List
      channelList: [],
      channlProps: {
        label: "childName"
      },
      //添加商家
      activeName: "1",
      merchantStaticTableData: [],
      dialogVisibleMerchant: false,
      merchantTableData: [],
      merchantListTotal: 0,
      productListloading: false,
      multipleMerchantSelection: [],
      merchantDataForm: {
        start: 1,
        limit: 10
      },
      addMerchantSelect: [],

      //添加店铺
      storeTableData: [],
      dialogVisibleStore: false,
      multipleStoreSelection: [],
      storeDataForm: {
        start: 1,
        limit: 10
      },
      storeAddTableData: [],
      addStoreSelect: [],
      storeListTotal: 0,

      //商品
      selectAddProduct: [],
      productTableData: [],
      productSelectFlag: [],
      proActiveName: "1",
      //触发场景
      triggerSceneForm: {
        userReceive: true,
          pageTrigger: true,
          triggerNum: 1
      },
      triggerSceneFormRules: {},
      //限制
      patchGrouponTableData: [], //拼团静态列表
      skillTableData: [], //秒杀静态列表
      triggerActiveName: "1",
      triggerVisible: false,
      triggerDataForm: {
        start: 1,
        limit: 10,
        promName:"",
        promotionId:"",
        id:""
      },
      triggerSelectData: [],
      triggerAddTableData: [],
      triggerListTotal: 0,

      //活动ID
      promotionId:
        this.$route.params.promotionId == null
          ? "0"
          : this.$route.params.promotionId,
      addTagDialogFormVisible: false, //添加标签弹框
      addTagForm: {},
      addTagRules: {
        categoryId: [
          { required: true, message: "请选择标签分类", trigger: "change" }
        ],
        tagName: [
          { required: true, message: "请输入标签名称", trigger: "blur" }
        ]
      },
      tagCategoryList: [],
      tagsList: [],

      deptType: localStorage.getItem("deptType"), //当前登录用户所属组织类型
      //商家页分页
      merchantStaticDataForm: {
        start: 1,
        limit: 10,
        merchantName: null,
        orgNumber: null
      },
      merchantTotal: 0,

      //商家页分页
      storeStaticDataForm: {
        start: 1,
        limit: 10,
        storename: null,
        storecode: null
      },
      storeTotal: 0,
      //商品也分页查询
      goodsTotal: 0,
      goodsStaticDataForm: {
        start: 1,
        limit: 10
      },
      skuTotal: 0, //已选择sku数量

      productStatusTabs: "1" ,   //商品tabs

      mutexMerchantProductTotalCount: 0 ,   //互斥Sku总条数
      mutexProductList: [] ,                //互斥商品List
      mutexProductForm: {
          start : 1,
          limit: 10,
          promotionId: this.promotionId,
          mutexFlag:1,//互斥标识
      },
      mutexProductTotal: 0,                 //互斥分页总条数
      showButtons:true,                     //功能按钮
      mutexPromotionList:[],                //查看详情弹窗
      mutexPromotionListTotal:0,
      mutexPromotionVisible:false,
      mutexPromotionForm:{
        promType: 1,
        start:1,
        limit:10,
      },

      isAllChecked: false,//全选
      isIndeterminateCheck: false,//全选 checkbox 的不确定状态
      allData: [],//全选 操作数据

      isAllProductChecked: false,//全选
      isIndeterminateProductCheck: false,//全选 checkbox 的不确定状态
      allProductData: [],//全选 操作数据

      searchMerchantFlag: false,
      searchStoreFlag: false,
      //商品搜索
      queryGoodsReuqest:{
        goodsType: null,
        goodsName: null,
        goodsCode: null,
        storeId: null,
      },
      searchGoodsFlag: false,

      //会员等级 会员类型
      memberGradeList: [],
      reloadMemLevel: true,

      //会员类型
      memTypeCheckAll: true,
      selectMemTypes:[1,2],
      memTypeIsIndeterminate: false,


      formRules:{
        checkRemark: [
          { required: true, message: "审核意见不能为空", trigger: "blur" }
        ]
      },

      userTypeCheckAll: true,
      selectUserType:[1,2],
      userTypeIsIndeterminate: false,

    };
  },
  methods: {
    queryChannelListOther: function() {
      var this_ = this;
      this.utils.request.queryChannelListOther({}, function(res) {
        if (res.code == "0000") {
          this_.channelOption = res.data;
        }
      });
    },
    //新老用户
    handleCheckAllUserTypeChange(val) {
      this.selectUserType = val ? [1,2] : [];
      this.userTypeIsIndeterminate = false;
    },
    handleCheckedUserTypeChange(value) {
      let checkedCount = value.length;
      this.userTypeCheckAll = checkedCount === 2;
      this.userTypeIsIndeterminate = checkedCount > 0 && checkedCount < 2;
    },
    getUuid() {
      var s = [];
      var hexDigits = "0123456789abcdef";
      for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
      }
      s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
      s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
      s[8] = s[13] = s[18] = s[23] = "-";

      var uuid = s.join("");
      return uuid;
    },
    //使用渠道选中时触发
    channelChange(callback){
      let deptNodeList = [];
      let deptIds = [];
      if(this.deptType == 0){
          deptNodeList = this.$refs.channelTree.getCheckedNodes();
          deptIds = deptNodeList.map((item,index) =>{
            return item.deptId;
          })
          if(deptIds.indexOf("179") == -1){
            deptIds.unshift("179");
            deptNodeList.unshift({"deptId":179,"childName":"卡奥斯运营中心","id":179})
          }

      }else{
        //查询子平台信息
        let deptId = localStorage.getItem("deptId");
        deptIds.push(deptId);
        let userInfo = JSON.parse(localStorage.getItem("user"));
        deptNodeList.push({deptId:userInfo.deptId,"childName":userInfo.deptName,"id":userInfo.businessId})
      }


      this.utils.request.listMemberGradeForMarket({"deptIds": deptIds.join(",")},res=>{
        if(res.code == '0000'){
            let levelList = res.data;
            let restLevelInfo =  [];
            //如果存在排除重新赋值
            this.memberGradeList.forEach(levelItem=>{
              let levelInfo = levelList.find(function(level) {
                return levelItem.deptId == level.deptId;
              })
              if(levelInfo != undefined){
                restLevelInfo.push(levelItem);
              }
            })
            //遍历
            this.memberGradeList = restLevelInfo;
            for(let deptInfo of deptNodeList){
              let levelItem = this.memberGradeList.find(function(level) {
                return deptInfo.deptId == level.deptId;
              })
              if(levelItem != undefined){
                continue;
              }
              //如果不勾选子平台 删除已有子平台

              let levelInfo = levelList.find(function(level) {
                return level.deptId == deptInfo.deptId;
              })
              if(levelInfo == undefined){
                this.memberGradeList.push({ deptId: deptInfo.deptId, childName: deptInfo.childName, businessId: deptInfo.id ,checkAll: true, isIndeterminate: false,  levelSelectList: [], levelList:[]})
              }else{
                //添加数据
                let selectLevelIds = levelInfo.mememberGradeResponseList.map((item,index) =>{
                  return item.id;
                })
                levelInfo.mememberGradeResponseList.forEach(item=>{
                  item.key = this.getUuid();
                })
                this.memberGradeList.push({deptId: deptInfo.deptId, childName: deptInfo.childName, businessId: deptInfo.id ,  levelSelectList: selectLevelIds,  checkAll: true , isIndeterminate: false , levelList:levelInfo.mememberGradeResponseList})
              }
            }

        }else{
          this.memberGradeList = [];
        }
        this.$nextTick(()=>{
          if(callback != undefined){
            callback();
          }
        })
      })
      // this.getMemLevelList(deptIds.join(","))
    },

    //会员类型
    handleCheckAllMemTypeChange(val) {
      this.selectMemTypes = val ? [1,2] : [];
      this.memTypeIsIndeterminate = false;
    },
    handleCheckedMemTypeChange(value) {
      let checkedCount = value.length;
      this.memTypeCheckAll = checkedCount === 2;
      this.memTypeIsIndeterminate = checkedCount > 0 && checkedCount < 2;
    },

    //会员等级
    handleMemLevelCheckAllChange(index,checked){
        if(!checked){
            //取消全部
            let memberSelectGrade = this.memberGradeList[index];
            memberSelectGrade.checkAll = false;
            memberSelectGrade.isIndeterminate = false;
            memberSelectGrade.levelSelectList = [];
            // this.$s
            this.$set(this.memberGradeList,index,memberSelectGrade);

        }else{
            //选中全部
            let ids = [];
            this.memberGradeList[index].levelList.forEach(item=>{
                ids.push(item.id)
            })
            let memberSelectGrade = this.memberGradeList[index];
            memberSelectGrade.checkAll = true;
            memberSelectGrade.isIndeterminate = false;
            memberSelectGrade.levelSelectList = ids;
            // this.$s
            this.$set(this.memberGradeList,index,memberSelectGrade);
        }
    },
    memLevelChange(index, levelList){
        //查看当前子平台是否全选
        let levelSelectList = this.memberGradeList[index].levelSelectList;
        if(levelSelectList == null || levelSelectList.length < 1){
            //没有选中子级
            let memberSelectGrade = this.memberGradeList[index];
            memberSelectGrade.checkAll = false;
            memberSelectGrade.isIndeterminate = false;
            memberSelectGrade.levelSelectList = [];
            // this.$s
            this.$set(this.memberGradeList,index,memberSelectGrade);
            return;
        }
        let noSelectIds = [];
        levelList.forEach(item=>{
            if(levelSelectList.indexOf(item.id) == -1){
                //存在
                noSelectIds.push(item.id);
            }
        })

        if(noSelectIds.length < 1){
            //全选
            let ids = [];
            this.memberGradeList[index].levelList.forEach(item=>{
                ids.push(item.id)
            })
            let memberSelectGrade = this.memberGradeList[index];
            memberSelectGrade.checkAll = true;
            memberSelectGrade.isIndeterminate = false;
            memberSelectGrade.levelSelectList = ids;
            this.$set(this.memberGradeList,index,memberSelectGrade);
        }else{
            //没有全选
            let ids = [];
            let memberSelectGrade = this.memberGradeList[index];
            memberSelectGrade.checkAll = false;
            memberSelectGrade.isIndeterminate = true;
            this.$set(this.memberGradeList,index,memberSelectGrade);
        }


    },
    /**
     * 重置商品搜索
     */
    resetStaticGoodsSearch(){
      //需要校验的keys
      let keys = ["storeId","goodsCode","goodsName","goodsType"]
      //调用校验
      let  boo = this.seachTableUtils.checkFromIsNull(this.queryGoodsReuqest,keys)
      if(!boo){
        return;
      }
      if (this.$refs['queryGoodsReuqest'] != undefined) {
        this.$refs['queryGoodsReuqest'].resetFields();
      }
      this.goodsStaticDataForm.start = 1;
      this.goodsStaticDataForm.limit = 10;
      this.skillQueryGoods();
    },
    /**
     * 重置商家页面搜索
     */
    resetStaticStoreSearch() {
      //需要校验的keys
      let keys = ["storename","storecode"]
      //调用校验
      let  boo = this.seachTableUtils.checkFromIsNull(this.storeStaticDataForm,keys)
      if(!boo){
        return;
      }
      if (this.$refs['storeStaticDataForm'] != undefined) {
        this.$refs['storeStaticDataForm'].resetFields();
      }
      this.storeStaticDataForm.start = 1;
      this.storeStaticDataForm.limit = 10;
      this.skillQueryStore();
    },
    /**
     * 重置商家页面搜索
     */
    resetMerchantSearch() {
      //需要校验的keys
      let keys = ["merchantName","orgNumber"]
      //调用校验
      let  boo = this.seachTableUtils.checkFromIsNull(this.merchantStaticDataForm,keys)
      if(!boo){
        return;
      }
      if (this.$refs['merchantStaticDataForm'] != undefined) {
        this.$refs['merchantStaticDataForm'].resetFields();
      }
      this.merchantStaticDataForm.start = 1;
      this.merchantStaticDataForm.limit = 10;
      this.skillQueryMerchant();
    },

     handleCheckedAllChange(value) {
      ////
      this.isIndeterminateCheck = false;

      this.allData.forEach(f => {
        f.isCheck = value;
        f.isIndeterminateCheck = false;
      });
    },
    handleCheckedChange(row, checked) {
      ////
      if (row.isIndeterminateCheck) {
        row.isCheck = true;
        checked = true;
      }
      row.isIndeterminateCheck = false;

      changeChild(row, checked);
      changeParent(row, this.allData);

      this.isAllChecked = this.allData.every(e => {
        return e.isCheck;
      });

      this.isIndeterminateCheck =
        !this.isAllChecked &&
        this.allData.some(e => {
          return e.isCheck;
        });
    },

    handleCheckedAllProductChange(value) {
      ////
      this.isIndeterminateProductCheck = false;

      this.allProductData.forEach(f => {
        f.isCheck = value;
        f.isIndeterminateCheck = false;
      });
    },
    handleCheckedProductChange(row, checked) {
      ////
      if (row.isIndeterminateCheck) {
        row.isCheck = true;
        checked = true;
      }
      row.isIndeterminateCheck = false;

      changeChild(row, checked);
      changeParent(row, this.allProductData);

      this.isAllProductChecked = this.allProductData.every(e => {
        return e.isCheck;
      });

      this.isIndeterminateProductCheck =
        !this.isAllProductChecked &&
        this.allProductData.some(e => {
          return e.isCheck;
        });
    },

      /**
     * 状态格式化
     */
    statusFormat(row){
      if(row.status == 1 && new Date().getTime() <= new Date(row.startTime).getTime()){
        //待提交
          return 11;
      }else if(row.status == 2 && new Date().getTime() <= new Date(row.startTime).getTime()){
        //待审核
        return 12;
      }else if(row.status == 11 && new Date().getTime() <= new Date(row.startTime).getTime()){
        //未开始
        return 13;
      }else if(row.status == 4 && new Date().getTime() <= new Date(row.startTime).getTime()){
        //审核未通过
        return 14;
      }else if(row.status == 11 && new Date().getTime() >= new Date(row.startTime).getTime() && new Date().getTime() <= new Date(row.endTime).getTime()){
        //进行中
        return 15;
      }else if((row.status == 1 || row.status ==  2 || row.status == 4) && new Date().getTime() > new Date(row.startTime).getTime()){
        //已过期
        return 16;
      }else if(row.status == 11 && new Date().getTime() > new Date(row.endTime).getTime()){
        //已结束
        return 17;
      }else{
        return row.status;
      }
    },
      linkInfoByMutexProduct(promotionId){
        this.$router.push(`/RedEnvelopeDetail?promotionId=${promotionId}`);
      },
      /**
     * 查询互斥商品
     */
    getMutexProductList() {
      var this_ = this;
      this.mutexProductForm.promotionId = this.promotionId;
      this.utils.request.queryRedGoodsByPromotionId(this.mutexProductForm, res => {
        if (res.code == "0000") {
          this_.mutexProductList = res.data.goodsInfoList;
          this_.allData = getAllRow(this_.mutexProductList, []);
          this_.mutexProductTotal = Number(res.data.total);
          this_.mutexMerchantProductTotalCount = res.data.skuTotal == null ? 0 : res.data.skuTotal;
          this.isIndeterminateCheck = false;
          this.isAllChecked = false;
        }
      });
    },
    /**
     * 每页条数改变触发
     */
    handleSizeChangeMutexProductList(val){
      this.mutexProductForm.limit = val;
      this.mutexProductForm.start = 1;
      this.getMutexProductList();
    },
    /**
     * 换页刷新
     */
    handleCurrentChangeMutexProductList(val){
      this.merchantProductSearchForm.start = val;
      this.getMutexProductList();
    },

    /**
     * 互斥商品重新添加
     */
    renewAdd(row){
      let that = this;
      let param = {};
      var productIdList = [];
      param.promotionId = this.promotionId;
      if(row.spuId == '0'){
          row.children.forEach(item=>{
            productIdList.push({"id":item.id,"goodsId": item.goodsId});
          })
      }else{
        productIdList.push({"id":row.id,"goodsId": row.goodsId});
      }
      if(productIdList.length < 1){
          this.$message({ message: "未选择重新添加条目", type: "error" });
          return false;
        }
      param.goodsInfoList = productIdList;
      this.utils.request.rendRedAdd(param,res=>{
        if(res.code=='0000'){
          that.getMutexProductList();
          that.skillQueryGoods();

          let data = res.data;
          if(data.businessCode == '0001'){
            this.$message({message: data.businessMsg, type: "success"});
          }else if(data.businessCode == '0002'){
            this.$message({message:data.businessMsg, type: "error"})
          }else if(data.businessCode == '0003'){
            this.$alert(data.businessMsg, '提示', {
              confirmButtonText: '知道了',
              callback: action => {}
            });
          }
        }
      });
    },

    /**
     * 批量重新添加选择数据
     */
    batchRenewAddSelectionChange(val) {
      this.batchRenewAddSelection = val;
    },

    /**
     * 批量重新添加
     */
    batchRenewAdd(){
      let that = this;
      let param = {};
      var productIdList = [];
      param.promotionId = this.promotionId;
      this.allData.forEach(row=>{
        if(row.isCheck && row.spuId != '0'){
          productIdList.push({"id":row.id,"goodsId": row.goodsId});
        }
      })
      if (productIdList.length < 1) {
        this.$message({ message: "未选择重新添加条目", type: "error" });
        return;
      }
      param.goodsInfoList = productIdList;
      this.utils.request.rendRedAdd(param,res=>{
        if(res.code=='0000'){
          that.getMutexProductList();
          that.skillQueryGoods();

          let data = res.data;
          if(data.businessCode == '0001'){
            this.$message({message: data.businessMsg, type: "success"});
          }else if(data.businessCode == '0002'){
            this.$message({message:data.businessMsg, type: "error"})
          }else if(data.businessCode == '0003'){
            this.$alert(data.businessMsg, '提示', {
              confirmButtonText: '知道了',
              callback: action => {}
            });
          }
        }
      });
    },
    /**
     * 生效商品 互斥商品tab选中触发
     */
    productTabs(tab){
      if(tab.index==0){
        this.showButtons = true;
      }else{
        this.showButtons = false;
      }
    },
    /**
     * 互斥商品查看详情
     */
    getMutexInfo(row){
      let that = this;
      this.mutexPromotionForm.start = 1;
      this.mutexPromotionForm.limit = 10;
      this.mutexPromotionForm.promotionId = this.promotionId;
      this.mutexPromotionForm.promotionMerchantProductId = row.id;
      this.getPromotionMutexListByProductId();
    },
    getPromotionMutexListByProductId(){
      let that = this;
      this.utils.request.queryRedMutexDetailPromotionList(this.mutexPromotionForm,res=>{
        if(res.code=='0000'){
            that.mutexPromotionList = res.data.rows;
            that.mutexPromotionListTotal = Number(res.data.total);
            that.mutexPromotionVisible = true;
        }
      });
    },

    /**
     * 每页条数改变触发
     */
    mutexPromotionListSizeChange(val){

      this.mutexPromotionForm.limit = val;
      this.mutexPromotionForm.start = 1;
      this.getPromotionMutexListByProductId();
    },
    /**
     * 换页刷新
     */
    mutexPromotionListCurrentChange(val){

      this.mutexPromotionForm.start = val;
      this.getPromotionMutexListByProductId();
    },



    //优惠方式联动
    changeCouponMode(data) {
      //金额
      if (data == 0) {
        this.promotionMethod = true;
        this.discountMethod = false;
      } else if (data == 1) {
        this.promotionMethod = false;
        this.discountMethod = true;
      }
    },
    /**
     * 清空店铺输入框
     */
    restStoreForm() {
      //需要校验的keys
      let keys = ["storeCode","storeName","storeType","merchantName"]
      //调用校验
      let  boo = this.seachTableUtils.checkFromIsNull(this.storeDataForm,keys)
      if(!boo){
        return;
      }

      this.$set(this.storeDataForm, "storeCode", null);
      this.$set(this.storeDataForm, "storeName", null);
      this.$set(this.storeDataForm, "storeType", null);
      this.$set(this.storeDataForm, "merchantName", null);
      this.$set(this.storeDataForm, "start", 1);
      this.queryPageStoreList();
    },
    /**
     * 清空商品输入框
     */
    restProductForm() {
      //需要校验的keys
      let keys = ["goodsName","goodsCategory","thirdSpuId","storeName"]
      //调用校验
      let  boo = this.seachTableUtils.checkFromIsNull(this.formInline,keys)
      if(!boo){
        return;
      }

      this.$set(this.formInline, "goodsName", null);
      this.$set(this.formInline, "goodsCategory", null);
      this.$set(this.formInline, "thirdSpuId", null);
      this.$set(this.formInline, "storeName", null);
      this.$set(this.formInline, "start", 1);
      this.queryPageProductManagement();
    },
    /**
     * channelIdsChange
     */
    channelIdsChange(val, checkedKeys) {
      this.$set(this.dataForm, "channelIds", checkedKeys.checkedKeys);
      this.channelChange();
    },
    /**
     * 添加全部商品
     */
    saveAllGoods() {
      // const loading = this.$loading({
      //   lock: true,
      //   text: "小的正在加载中,请稍后...",
      //   spinner: "el-icon-loading",
      //   background: "rgba(0, 0, 0, 0.7)"
      // });
      this.utils.request.couponAddAllGoods(
        { promotionId: this.promotionId },
        res => {
          // loading.close();
          this.goodsCurrentChange(1);
          this.getMutexProductList();
          //TODO
        }
      );
    },
    /**
     * 商品页分页
     */
    goodsSizeChange() {},
    goodsCurrentChange(val) {
      this.goodsStaticDataForm.start = val;
      this.skillQueryGoods();
    },
    /**
     * 商家页分页
     */
    merchantSizeChange() {},
    merchantCurrentChange(val) {
      this.merchantStaticDataForm.start = val;
      this.skillQueryMerchant();
    },
    /**
     * 店铺
     */
    storeSizeChange() {},
    storeCurrentChange(val) {
      this.storeStaticDataForm.start = val;
      this.skillQueryStore();
    },
    /**
     * 清空商家搜索框
     */
    restMerchantForm() {
      //需要校验的keys
      let keys = ["orgNumber","name","merchantType"]
      //调用校验
      let  boo = this.seachTableUtils.checkFromIsNull(this.merchantDataForm,keys)
      if(!boo){
        return;
      }

      this.$set(this.merchantDataForm, "orgNumber", "");
      this.$set(this.merchantDataForm, "name", "");
      this.$set(this.merchantDataForm, "start", 1);
      this.$set(this.merchantDataForm, "merchantType", '');
      this.queryPageMerchantList();
    },
    /**
     * 弹窗条件查询商家
     */
    queryPageMerchantManagement() {
      this.merchantDataForm.start = 1;
      this.queryPageMerchantList();
    },
    /**
     * 保存模板
     */
    saveTemplate() {
      var that = this;
      this.templateForm.promotionId = this.promotionId;
      if (
        this.templateForm.templateName == null ||
        this.templateForm.templateName == ""
      ) {
        that.$message({ message: "模板名称不能为空", type: "error" });
        return false;
      }
      // const loading = this.$loading({
      //   lock: true,
      //   text: "小的正在加载中,请稍后...",
      //   spinner: "el-icon-loading",
      //   background: "rgba(0, 0, 0, 0.7)"
      // });
      this.utils.request.couponSaveTemplate(this.templateForm, res => {
        // loading.close();
        if (res.code == "0000") {
          this.$message({ message: "保存成功", type: "success" });
          this.templateDialogFormVisible = false;
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
      });
    },
    //新老用户
    handleCheckAllChange2(val) {
      this.dataForm.proUserType = val
        ? proUserTypeRadio.map(function(value, index, array) {
            return value.code;
          })
        : [];
      this.isIndeterminate2 = false;
    },
    handleCheckedCitiesChange2(value) {
      let checkedCount = value.length;
      this.checkAll2 = checkedCount === this.proUserTypeRadios.length;
      this.isIndeterminate2 =
        checkedCount > 0 && checkedCount < this.proUserTypeRadios.length;
    },
    /**
     * 新增标签弹窗
     */
    addtags() {
      if (this.$refs["addTagForm"] != undefined) {
        this.$refs["addTagForm"].resetFields();
      }
      this.addTagDialogFormVisible = true;
    },
    /**
     * 新增标签
     */
    addNewTag() {
      this.$refs["addTagForm"].validate(valid => {
        if (valid) {
          //TODO 新增标签
          // this.addTagForm
          let that = this;
          this.utils.request.addTag(this.addTagForm, res => {
            that.queryTagList(res.data);
            that.addTagDialogFormVisible = false;
          });
        } else {
          return false;
        }
      });
    },
    /**
     * 查询标签List
     */
    queryTagList(id) {
      let that = this;
      this.utils.request.getTagList({}, res => {
        this.tagsList = res.data.rows;
        // if (this.skillId != "0") {
        //   this.getSkillDetail();
        // }
        if (id != null) {
          this.dataForm.label = id;
        }
      });
    },
    /**
     * 标签分类查询
     */
    getTagCategoryList() {
      let that = this;
      this.utils.request.getTagCategoryList({}, res => {
        this.tagCategoryList = res.data.rows;
      });
    },

    promotionIdSet(val) {
      this.promotionId = val.promotionId;
    },
    /**
     * 查询触发场景
     */
    queryTriggerList() {
      //查询触发场景
      this.utils.request.couponQueryTrigger(
        { promotionId: this.promotionId },
        res => {
          if (res != null && res.data != null) {
            let triggerType = res.data.triggerType;
            triggerType.forEach(trigger => {
              let triggerIds = trigger.split(",");
              triggerIds.forEach(item => {
                if (item == "00") {
                  this.$set(this.triggerSceneForm, "pageTrigger", true);
                } else if (item == "10") {
                  this.$set(this.triggerSceneForm, "userRegistered", true);
                } else if (item == "11") {
                  this.$set(this.triggerSceneForm, "userDetail", true);
                } else if (item == "31") {
                  this.$set(this.triggerSceneForm, "sign", true);
                } else if (item == "32") {
                  this.$set(this.triggerSceneForm, "favorite", true);
                } else if (item == "33") {
                  this.$set(this.triggerSceneForm, "lottery", true);
                }
              });
              //TODo
            });

            this.utils.request.patchGrouponThemeQueryListByIds(
              { ids: res.data.patchGroupTriggerList },
              result => {
                if (result.code == "0000") {
                  this.patchGrouponTableData = result.data;
                }
              }
            );
            this.utils.request.skillQueryConfigList(
              { promotionIdList: res.data.speedKillTriggerList },
              result => {
                if (result.code == "0000") {
                  this.skillTableData = result.data;
                }
              }
            );
          }
        }
      );
    },
    /**
     * 确认添加活动
     */
    addTriggerChange() {
      if (this.triggerActiveName == "1") {
        //拼团
        if (this.triggerSelectData.length < 1) {
          this.$message({ message: "请选择要添加的活动", type: "error" });
          return false;
        }
        this.patchGrouponTableData = this.triggerSelectData;
        this.triggerSelectData = [];
      } else {
        //秒杀
        if (this.triggerSelectData.length < 1) {
          this.$message({ message: "请选择要添加的活动", type: "error" });
          return false;
        }
        this.skillTableData = this.triggerSelectData;
        this.triggerSelectData = [];
      }
      this.triggerVisible = false;
    },
    /**
     * 选择活动
     */
    addTriggerChangeSelect(val) {
      this.triggerSelectData = val;
    },
    /**
     * 查询活动列表
     */
    queryPageTriggerManagement() {},
    /**
     * 条数刷新
     */
    triggerhandleSizeChange(val) {},
    /**
     * 换页刷新
     */
    triggerhandleCurrentChange(val) {
      this.$refs["triggerDataForm"].validate(valid => {
        if (valid) {
          this.triggerDataForm.start = val;
          if (this.triggerActiveName == "1") {
            //拼团
            this.queryGrouponPage();
          } else {
            //秒杀
            this.querySkillPage();
          }
        }
      });
    },
    /**
     * 添加活动
     */
    addTrigger() {
      this.triggerVisible = true;
      this.triggerAddTableData = [];
      //查询活动列表
      if (this.triggerActiveName == "1") {
        //拼团
        this.queryGrouponPage();
      } else {
        //秒杀
        this.querySkillPage();
      }
    },
    /**
     * 查询秒杀活动
     */
    querySkillPage() {
      this.triggerDataForm.promType = 4;
      this.triggerDataForm["pageNo"] = this.triggerDataForm.start;
      this.triggerDataForm["pageSize"] = this.triggerDataForm.limit;
      let this_ = this;
      this.utils.request.promotionList(this.triggerDataForm, function(res) {
        if (res.code == "0000") {
          this_.triggerAddTableData = res.data.list;
          this_.triggerListTotal = res.data.totalCount;
        }
      })
    },
    /**
     * 查询拼团活动
     */
    queryGrouponPage() {
      this.triggerDataForm.promType = null;
      this.triggerDataForm["pageNo"] = this.triggerDataForm["start"];
      this.triggerDataForm["pageSize"] = this.triggerDataForm["limit"];
      this.utils.request.grouponQueryPage(this.triggerDataForm, res => {
        this.triggerAddTableData = res.data.list;
        this.triggerListTotal = res.data.totalCount;
      });
    },
    /**
     * 删除限制
     */
    deleteTrigger(index, row) {
      if (this.triggerActiveName == "1") {
        //拼团
        this.patchGrouponTableData.splice(index, 1);
      } else {
        this.skillTableData.splice(index, 1);
      }
    },
    /**
     * 活动发放tabs切换
     */
    triggerActiveClick(val) {
      this.$set(this.triggerDataForm,"id",'');
      this.$set(this.triggerDataForm,"promotionId",'');
      this.$set(this.triggerDataForm,"promName",'');
    },
    /**
     * 确认添加商品
     */
    addProductChange(val) {
      if (this.selectAddProduct.length < 1) {
        this.$message({ message: "请选择要添加的商品", type: "warning" });
        return false;
      }
      let tableData = this.productTableData.concat(this.mutexProductList);

      tableData.forEach(res => {
        this.selectAddProduct.forEach((item, index) => {
          //排除已保存过的商品
          if (res.goodsId == item.id) {
            this.selectAddProduct.splice(index, 1);
          }
        });
      });
      if (this.selectAddProduct && this.selectAddProduct.length > 0) {
        this.productTableData = this.productTableData.concat(
          this.selectAddProduct
        );
        this.dialogVisibleTwo = !this.dialogVisibleTwo;
        this.relatedProducts();
      } else {
        this.dialogVisibleTwo = !this.dialogVisibleTwo;
      }
    },
    /* 关联商品 */
    relatedProducts() {
      //this.active = this.active + 1;
      if (this.productTableData.length < 1) {
        this.$message({ message: "所关联的商品不能为空", type: "warning" });
        return false;
      }
      // const loading = this.$loading({
      //   lock: true,
      //   text: "小的正在努力加载中......",
      //   spinner: "el-icon-loading",
      //   background: "rgba(0, 0, 0, 0.8)"
      // });
      let that = this;
      let param = this.selectAddProduct.map(item => item.id);
      this.utils.request.couponAddGoods(
        { promotionId: this.promotionId, goodsInfoList: param },
        res => {
          // loading.close();
          if (res != null && res.data != null && res.code == "0000") {
            //商品新增成功
            that.skillQueryGoods();
            that.getMutexProductList();
            that.selectAddProduct = [];
          }
        }
      );
    },
    /**
     * 查询绑定的商品
     */
    skillQueryGoods(index) {
      let that = this;
      this.goodsStaticDataForm.promotionId = this.promotionId;
      this.goodsStaticDataForm.queryGoodsReuqest = this.queryGoodsReuqest;
      that.utils.request.queryRedGoodsByPromotionId(this.goodsStaticDataForm,
        data => {
          if (data != null) {
            if(data.data.goodsInfoList == null){
              that.productTableData = [];
              this.goodsTotal = Number(0);
              this.skuTotal = Number(0);
              this.isIndeterminateProductCheck = false;
              this.isAllProductChecked = false;
            }else{
              that.productTableData = data.data.goodsInfoList;
              // this.allProductData = this.productTableData;
              that.allProductData = getAllRow(that.productTableData, []);
              this.goodsTotal = Number(data.data.total);
              this.skuTotal = Number(data.data.skuTotal);
              this.isIndeterminateProductCheck = false;
              this.isAllProductChecked = false;
            }
          }
        }
      );
    },
    selectPorduct(val) {
      this.productSelectFlag = val;
    },
    /**
     * 条数刷新
     */
    producthandleSizeChange(val) {},
    /**
     * 换页刷新
     */
    producthandleCurrentChange(val) {
      this.formInline.start = val;
      this.queryPageProductManagement();
    },
    /**
     * 选择商品
     */
    selectAddProductChange(val) {
      this.selectAddProduct = val;
    },
    /**
     * 批量删除商品
     */
    batchDeleteProduct() {
      let ids = [];
      this.allProductData.forEach(function(item,index,array){
        //判断父下面是否全选
        if(item.mpParentId == null && item.isCheck){
          if(item.children && item.children.length > 0){
            let isCheckItems = item.children.filter(function (subItem, index) {
              return !subItem.isCheck;
            });
            if(!(isCheckItems && isCheckItems.length > 0)){
              ids.push(item.goodsId);
            }
          }else{
            ids.push(item.goodsId);
          }
        }else if(item.mpParentId != null && item.isCheck){
          ids.push(item.goodsId);
        }
      });
      if (ids.length < 1) {
        this.$message({ message: "请选择要删除的商品", type: "warning" });
        return false;
      }
      this.$confirm("确认批量删除已选内容？", "提示", {
        type: "warning",
        closeOnClickModal: false,
      })
        .then(() => {
          ids.forEach(item => {
            this.utils.request.couponDeleteGoods(
              { promotionId: this.promotionId, goodsId: item },
              res => {
                //查询表单
                this.skillQueryGoods();
              }
            );
          });
          this.productSelectFlag = [];
        })
        .catch(() => {});
    },
    deleteProduct(index, row) {
      let proId = row.goodsId;
      this.utils.request.couponDeleteGoods(
        { promotionId: this.promotionId, goodsId: proId },
        res => {
          this.skillQueryGoods();
        }
      );
    },
    /**
     * 弹窗选择店铺
     */
    addStoreChangeSelect(val) {
      this.addStoreSelect = val;
    },
    /**
     * 弹窗换页刷新
     */
    storehandleSizeChange(val) {
      this.storeDataForm.limit = val;
      this.queryPageStoreList();
    },
    /**
     * 弹窗翻页
     */
    storehandleCurrentChange(val) {
      this.storeDataForm.start = val;
      this.queryPageStoreList();
    },
    /**
     * 查询关联
     */
    skillQueryMerchant() {
      let that = this;
      this.merchantStaticDataForm.promotionId = this.promotionId;
      this.utils.request.couponQueryMerchant(
        this.merchantStaticDataForm,
        res => {
          if (res != null && res.data != null) {
            this.merchantStaticTableData =
              res.data.merchantInfoList == null
                ? []
                : res.data.merchantInfoList;
            let data = [];
            this.merchantStaticTableData.forEach(item => {
              data.push({
                orgNumber: item.orgNumber,
                id: item.merchantId,
                name: item.merchantName,
                merchantType: item.merchantTypeId
              });
            });
            this.merchantStaticTableData = data;
            this.merchantTotal = Number(res.data.total);
          }
        }
      );
    },
    /**
     * 查询关联的店铺
     */
    skillQueryStore() {
      let that = this;
      this.storeStaticDataForm.promotionId = this.promotionId;
      this.utils.request.couponQueryStore(this.storeStaticDataForm, res => {
        if (res != null && res.data != null) {
          this.storeTableData =
            res.data.storeInfoList == null ? [] : res.data.storeInfoList;
          let data = [];
          this.storeTableData.forEach(item => {
            data.push({
              id: item.storeId,
              storeName: item.storeName,
              storeCode: item.storeCode,
              merchantId: item.merchantId,
              merchantName: item.merchantName,
              storeType: item.storeType
            });
          });
          this.storeTableData = data;
          this.storeTotal = Number(res.data.total);
        }
      });
    },
    /**
     * 确认添加店铺
     */
    addStoreChange() {
      if (this.addStoreSelect.length < 1) {
        this.$message({ message: "请选择要添加的店铺", type: "warning" });
        return false;
      }
      this.storeTableData.forEach(res => {
        this.addStoreSelect.forEach((item, index) => {
          //排除已保存过的店铺
          if (res.id == item.id) {
            this.addStoreSelect.splice(index, 1);
          }
        });
      });
      if (this.addStoreSelect && this.addStoreSelect.length > 0) {
        let that = this;
        let paramData = [];
        this.addStoreSelect.forEach(item => {
          paramData.push({
            merchantId: item.merchantId,
            storeName: item.storeName,
            storeId: item.id,
            storeCode: item.storeCode,
            // "storeId":item.id,
            channelCode: ""
          });
        });
        let param = { promotionId: this.promotionId, storeInfoList: paramData };
        this.utils.request.couponAddStore(param, res => {
          this.dialogVisibleStore = !this.dialogVisibleStore;
          this.addStoreSelect = [];
          this.skillQueryStore();
        });
      } else {
        this.dialogVisibleStore = !this.dialogVisibleStore;
      }
    },
    /**
      添加店铺
      */
    addStore() {
      // ;
      if (this.merchantStaticTableData.length == 0) {
        this.$message({ message: "请先选择商家", type: "error" });
        return false;
      }
      this.queryPageStoreList();
      this.dialogVisibleStore = true;
    },
    /**
     * 批量删除店铺
     */
    batchDeleteStore() {
      if (this.multipleStoreSelection.length < 1) {
        this.$message({ message: "请选择要删除的店铺", type: "warning" });
        return false;
      }
      this.$confirm("确认批量删除已选内容？", "提示", {
        type: "warning",
        closeOnClickModal: false,
      })
        .then(() => {
          this.multipleStoreSelection.forEach(item => {
            for (let index = 0; index < this.storeTableData.length; index++) {
              if (this.storeTableData[index].id == item.id) {
                this.storeTableData.splice(index, 1);
              }
              this.utils.request.couponDeleteStore(
                { promotionId: this.promotionId, storeId: item.id },
                res => {}
              );
            }
          });
          this.multipleStoreSelection = [];
        })
        .catch(() => {});
    },
    /**
     * 选择店铺
     */
    selectStoreChange(val) {
      this.multipleStoreSelection = val;
    },
    /**
     * 新增商家选择
     */
    /**
     * 商家列表换页刷薰
     *
     */
    merchanthandleSizeChange(val) {
      this.merchantDataForm.limit = val;
      this.queryPageMerchantList();
    },
    merchanthandleCurrentChange(val) {
      this.merchantDataForm.start = val;
      this.queryPageMerchantList();
    },

    restForm() {
      this.$refs["triggerDataForm"].resetFields();
      this.$set(this.triggerDataForm,"start",1);
      this.$set(this.triggerDataForm,"limit",10);
      if (this.triggerActiveName == "1") {
        //拼团
        this.queryGrouponPage();
      } else {
        //秒杀
        this.querySkillPage();
      }
    },
    queryPageProductManagement() {
      let that = this;
      this.productListloading = true;
      //商品分类
      this.formInline.goodsCategory = this.formInline.goodsCategory == "" ? null : this.formInline.goodsCategory;
      //商品名称
      this.formInline.chineseName = this.formInline.goodsName == "" ? null : this.formInline.goodsName;
      //店铺名称
      this.formInline.storeName = this.formInline.storeName =="" ? null : this.formInline.storeName;
      //商品编码
      this.formInline.code = this.formInline.thirdSpuId =="" ? null : this.formInline.thirdSpuId ;

      // this.formInline.storeIds = this.storeTableData.map(item=>item.id);
      this.utils.request.getCouponStoreIdsByPromotionId(
        { promotionId: this.promotionId },
        data => {
          if (data.data == null && data.data.length < 1) {
            this.$message({ message: "请选择店铺", type: "error" });
            this.active = this.active - 1;
            return false;
          }
          this.formInline.storeIds = data.data;
          this.utils.request.promotionSpuPageByPromotionId(
            this.formInline,
            res => {
              that.productListloading = false;
                if (res.code == "0000") {
                  // that.tableDataTwo = res.data.rows;
                  that.tableDataTwo = res.data.rows.map((ele, index) => {
                    let spu = {};
                    spu.id = ele.id;
                    spu.thirdSpuId = ele.code;
                    spu.goodsName = ele.chineseName;
                    // spu.totalStock = ele.totalStock;
                    spu.goodsCategory = ele.fullNamePath;
                    // spu.merchantName = ele.merchantName;
                    spu.storeName = ele.storeName;
                    spu.salePriceScope = ele.salePriceWithTax;
                    // spu.measureUnit = ele.measureUnit;
                    return spu;
                  });
                  that.productListTotal = res.data.total;
                }
            }
          );
        }
      );
    },
    /**
      添加店铺
      */
    addStore() {
      // ;
      if (this.merchantStaticTableData.length == 0) {
        this.$message({ message: "请先选择商家", type: "error" });
        return false;
      }
      this.queryPageStoreList();
      this.dialogVisibleStore = true;
    },
    queryPageStoreList() {
      // let ids = this.merchantStaticTableData
      //   .map(item => item.orgNumber)
      //   .toString();
      // let idArray = (ids + "").split(",");
      // let params = [];
      // for (let i = 0; i < idArray.length; i++) {
      //   params.push({ id: idArray[i] });
      // }
      // if (this.merchantStaticTableData.length == 0) {
      //   this.$message({ message: "请先选择商家", type: "success" });
      //   return false;
      // }
      // let this_ = this;
      // this.storeDataForm.merchantIds = ids;
      this.utils.request.couponGetMerchantIdsByPromotionId(
        { promotionId: this.promotionId },
        data => {
          if (data.data.length == 0) {
            this.$message({ message: "请先选择商家", type: "success" });
            return false;
          }
          let this_ = this;
          this.storeDataForm.merchantIds = data.data.join(",");
          this.utils.request.queryByIds(this.storeDataForm, function(res) {
            if (res.code == "0000") {
              this_.storeAddTableData = res.data.rows;
              this_.storeListTotal = res.total;
            }
          });
        }
      );
    },
    /**
     * 批量删除店铺
     */
    // batchDeleteStore(){
    //     if(this.multipleStoreSelection.length < 1){
    //         this.$message({message:"请选择要删除的店铺",type:"warning"})
    //         return false;
    //     }
    //       this.$confirm("确定删除吗？", "提示", {
    //         type: "warning"
    //     }).then(() => {
    //         this.multipleStoreSelection.forEach(item=>{
    //             for(let index = 0 ; index < this.storeTableData.length ; index++){
    //                 if(this.storeTableData[index].id == item.id){
    //                     this.storeTableData.splice(index,1);
    //                 }

    //             }
    //         })
    //         this.multipleStoreSelection = [];
    //     }).catch(() => {});
    // },
    /**
     * 选择店铺
     */
    selectStoreChange(val) {
      this.multipleStoreSelection = val;
    },
    /**
     * 删除店铺
     */
    handleDeleteStore(index, row) {
      let proId = row.id;
      for (var i = 0; i < this.storeTableData.length; i++) {
        if (this.storeTableData[i].id == proId) {
          this.storeTableData.splice(i, 1);
          this.utils.request.couponDeleteStore(
            { promotionId: this.promotionId, storeId: proId },
            res => {}
          );
        }
      }
    },

    /**
     * 添加商家按钮
     */
    addMerchant() {
      // this.queryPageProductManagement();
      this.queryPageMerchantList();
      this.dialogVisibleMerchant = true;
    },
    queryPageMerchantList() {
      let that = this;
      this.productListloading = true;
      //只有运营平台有使用渠道
      if (this.deptType == 0) {
        this.merchantDataForm.childIds = that.dataForm.channelIds;
      }
      this.utils.request.queryMerchantList(this.merchantDataForm, res => {
        that.productListloading = false;
        if (res.code == "0000") {
          that.merchantTableData = res.data.rows;
          that.merchantListTotal = res.data.total;
        }
      });
    },
    /**
     * 多选商家
     */
    selectMerchantChange(val) {
      this.multipleMerchantSelection = val;
    },
    handleDelete(index, row) {
      let proId = row.id;
      for (var i = 0; i < this.merchantStaticTableData.length; i++) {
        if (this.merchantStaticTableData[i].id == proId) {
          this.merchantStaticTableData.splice(i, 1);
          this.utils.request.couponDeleteMerchant(
            { merchantId: proId, promotionId: this.promotionId },
            res => {
              this.merchantStaticDataForm.start = 1;
              this.storeStaticDataForm.start = 1;
              this.skillQueryMerchant();
              this.skillQueryStore();
            }
          );
        }
      }
    },
    /**
     * 批量删除商家
     */
    batchDeleteMerchant() {
      if (this.multipleMerchantSelection.length < 1) {
        this.$message({ message: "请选择要删除的商家", type: "warning" });
        return false;
      }
      this.$confirm("确认批量删除已选内容？", "提示", {
        type: "warning",
        closeOnClickModal: false,
      })
        .then(() => {
          this.multipleMerchantSelection.forEach(item => {
            for (
              let index = 0;
              index < this.merchantStaticTableData.length;
              index++
            ) {
              if (this.merchantStaticTableData[index].id == item.id) {
                this.merchantStaticTableData.splice(index, 1);
              }
              this.utils.request.couponDeleteMerchant(
                { merchantId: item.id, promotionId: this.promotionId },
                res => {
                  this.merchantStaticDataForm.start = 1;
                  this.storeStaticDataForm.start = 1;
                  this.skillQueryMerchant();
                  this.skillQueryStore();
                }
              );
            }
          });
          this.multipleMerchantSelection = [];
          //TODO 删除商家
        })
        .catch(() => {});
    },
    /**
     * 渠道选择
     */
    channelCheckChange(data, checked, indeterminate) {
      let index = this.dataForm.channelIds.indexOf(data.id);
      if (index != -1) {
        //存在
        this.dataForm.channelIds.splice(index, 1);
      } else {
        //不存在
        this.dataForm.channelIds.push(data.id);
      }
    },

    start_time(e) {
      this.dataForm.couponUseStartTime = formatDate(
        e[0],
        "yyyy-MM-dd hh:mm:ss"
      );
      this.dataForm.couponUseEndTime = formatDate(e[1], "yyyy-MM-dd hh:mm:ss");
    },
    activityTime(e) {
      this.dataForm.startTime = formatDate(e[0], "yyyy-MM-dd hh:mm:ss");
      this.dataForm.endTime = formatDate(e[1], "yyyy-MM-dd hh:mm:ss");
    },
    select(row) {
      let flag = true;
      this.tableData.forEach(res => {
        if (res.id == row.id) {
          this.$message({ message: "不能添加重复商品", type: "error" });
          flag = false;
        }
      });
      if (flag) {
        this.tableData.push(row);
        this.dialogVisibleTwo = !this.dialogVisibleTwo;
      }
    },
    handleChange(myArray) {},
    add() {
      this.queryPageProductManagement();
      this.dialogVisibleTwo = true;
    },
    //table的双色条纹
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex === 1) {
        return "warning-row";
      } else if (rowIndex === 3) {
        return "success-row";
      }
      return "";
    },
    //修改table header的背景色
    tableHeaderColor({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return "background-color:rgb(250,250,250);";
      }
    },
    //table的编辑和删除
    handleEdit(index, row) {
      row.disabled = !row.disabled;
    },
    handleRemove(file, fileList) {},
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    next() {
      if (this.active == 1) {
        //提交订单
        this.submitCouponInfo("dataForm");
      } else if (this.active == 2) {
        //关联商品
        // this.relatedProducts();
      
        this.queryTriggerList();
        this.addActive();
      } else if (this.active == 3) {
        //触发场景 保存触发场景
        let param = {};
        param.promotionId = this.promotionId;
        param.pageTrigger =
          this.triggerSceneForm.pageTrigger == true ? "00" : "";
        param.systemTrigger =
          this.triggerSceneForm.userRegistered == true ? "10" : "";
        param.systemTrigger =
          this.triggerSceneForm.userRegistered == true
            ? param.systemTrigger + "," + "11"
            : param.systemTrigger + "";
        param.taskTrigger = this.triggerSceneForm.sign == true ? "31" : "";
        param.taskTrigger =
          this.triggerSceneForm.favorite == true
            ? param.taskTrigger + "," + "32"
            : param.taskTrigger + "";

        //编辑data
        param.patchGroupTriggerList =
          this.patchGrouponTableData == null
            ? []
            : this.patchGrouponTableData.map(item => item.id);
        param.speedKillTriggerList =
          this.skillTableData == null
            ? []
            : this.skillTableData.map(item => item.id);

        this.utils.request.couponUpdateTrigger(param, res => {
          //调用审核接口 改成待提交
          if (this.dataForm.status == 9 || this.dataForm.status == null) {
            this.utils.request.couponCheckCoupon(
              { promotionId: this.promotionId, updateStatus: "1" },
              data => {
                this.dataForm.status = 1;
                this.addActive();
              }
            );
          }else{
            this.addActive();
          }
        });
      }
    },
    addActive() {
      this.active = parseInt(this.active)  + 1;
      this.$router.push({ params: { promotionId: this.promotionId ,active:this.active} })
      if (this.active > 5) {
        this.$router.push({
          path: "/pages/promotionManagement/RedEnvelopeManagerList"
        });
      }
    },
    back() {
      this.active = parseInt(this.active) - 1;
      this.$router.push({ params: { promotionId: this.promotionId ,active:this.active} })
      this.nextOrBack();
    },
    viewList() {
      // this.$emit("viewList");
      this.$router.push("/pages/promotionManagement/RedEnvelopeManagerList");
    },
    shenheHuodong(flag) {
      if (flag == 0) {
        //提交审核
        let that = this;
        this.$confirm("确认提交审核？", "提示", {
            type: "warning",
            closeOnClickModal: false,
          }).then(() => {
            this.utils.request.couponCheckCoupon(
              { promotionId: this.promotionId, updateStatus: "2" },
              res => {
                this.shenhe = 1;
                this.$set(this.dataForm,"status",12);
                that.$message({ message: "提交审核成功", type: "success" });
                that.couponQueryConfigByPromotionId();
              }
            );
          })
      } else {
        //审核
        this.dialogFormVisible = true;
      }
      // this.$message({ message: "操作成功", type: "success" });
    },
    change(e) {
      if (e.indexOf("全部") > -1) {
        this.dataForm.couponUsePersonType = [];
        this.dataForm.couponUsePersonType.push("0");
        this.dataForm.couponUsePersonType.push("1");
        this.dataForm.couponUsePersonType.push("2");
      }
    },
    dateFilter: function(input) {
      var d = new Date(input);
      var year = d.getFullYear();
      var month =
        d.getMonth() < 9 ? "0" + (d.getMonth() + 1) : "" + (d.getMonth() + 1);
      var day = d.getDate() < 10 ? "0" + d.getDate() : "" + d.getDate();
      var hour = d.getHours() < 10 ? "0" + d.getHours() : "" + d.getHours();
      var minutes =
        d.getMinutes() < 10 ? "0" + d.getMinutes() : "" + d.getMinutes();
      var seconds =
        d.getSeconds() < 10 ? "0" + d.getSeconds() : "" + d.getSeconds();
      return (
        year +
        "-" +
        month +
        "-" +
        day +
        " " +
        hour +
        ":" +
        minutes +
        ":" +
        seconds
      );
    },
    /* 提交红包信息 */
    submitCouponInfo(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          //如分摊则校验分摊比例总和不能超过100
          if (this.dataForm.costAllocationFlag == "1" && this.deptType != 3) {
            if (
              Number(this.dataForm.parentAllocationScale || 0) +
                Number(this.dataForm.childAllocationScale || 0) +
                Number(this.dataForm.merchantAllocationScale || 0) +
                Number(this.dataForm.storeAllocationScale || 0) !=
              100
            ) {
              this.$message({ message: "分摊比例总和为100", type: "warning" });
              // loading.close();
              return false;
            }
          }

          //如果是店铺 自己分摊100
          if(this.deptType == 3){
            this.dataForm.costAllocationFlag = "1"
            this.dataForm.storeAllocationScale = 100;
          }
          //使用渠道
          //当前登录用户身份为母平台校验所属渠道
          // if (this.deptType == 0) {
          //   if (this.$refs.channelTree.getCheckedKeys().length <= 0) {
          //     this.$message({ message: "请选择使用渠道" });
          //     // loading.close();
          //     return false;
          //   } else {
          //     this.dataForm.channelCodes = this.$refs.channelTree
          //       .getCheckedKeys()
          //       .join(",");
          //   }
          // } else {
          //   //非母平台清除子平台编码
          //   if (this.dataForm.channelCodes) {
          //     delete this.dataForm.channelCodes;
          //   }
          // }

          this.dataForm.memTypes = this.selectMemTypes.join(",")
          this.dataForm.proUserType = this.selectUserType.join(",");
          this.dataForm.promotionMemberGradeList = [];

          this.memberGradeList.forEach(item=>{
            this.dataForm.promotionMemberGradeList.push({platformId:item.businessId,levelCodeList:item.levelSelectList})
          })

          let that = this;
          if (this.promotionId == "0") {
            this.utils.request.couponAddConfig(this.dataForm, res => {
              // loading.close();
              if (res.code == "0000") {
                that.promotionId = res.data;
                this.skillQueryMerchant();
                this.skillQueryStore();
                this.addActive();
              } else {
                that.$message({
                  message: res.msg || "新增红包失败,请重试",
                  type: "error"
                });
              }
            });
          } else {
            if(this.dataForm.discountLimit == 'null'){
              this.dataForm.discountLimit = null;
            }
            //编辑
            this.dataForm.promotionId = this.promotionId;
            this.utils.request.couponUpdateConfig(this.dataForm, res => {
              // loading.close();
              if (res.code == "0000") {
                this.skillQueryMerchant();
                this.skillQueryStore();
                this.addActive();
              } else {
                that.$message({
                  message: res.msg || "新增红包失败,请重试",
                  type: "error"
                });
              }
            });
          }
        } else {
          // this.$message({ message: "新增红包失败,请重试", type: "error" });
          return false;
        }
      });
    },
    reviewDialog: function(data) {
      let that = this;
      this.form.promotionId = this.promotionId;
      this.form.updateStatus = data;
      if (
          data == 4
        ) {
           this.$refs.form.validate(auditRemarkE => {
              if (auditRemarkE) {

              }else{
                throw Error("");
              }
            })
        }
      that.utils.request.couponCheckCoupon(this.form, res => {
        if (res.code == "0000") {
          that.dialogFormVisible = false;
          that.$message({ message: "审核完成", type: "success" });
          // that.findPage();
          that.shenhe = 2;
        } else {
          that.$message({ message: "审核失败", type: "error" });
        }
        that.couponQueryConfigByPromotionId();
      });
    },
    initData: function() {
      this.dataForm.url = "jic-market/coupon/template/query-template";
      this.dataForm.templateId = this.temId;
      this.utils.request.httpUtils(this.dataForm, res => {
        if (res.code == "0000") {
          for (var key in res.data) {
            this.dataForm[key] = res.data[key].toString();
          }
          this.dataForm.activityTime[0] = res.data.activityStartTime;
          this.dataForm.activityTime[1] = res.data.activityEndTime;
          this.dataForm.proportion = res.data.costAllocationScore;
          this.dataForm.couponUseTime[0] = res.data.couponUseStartTime;
          this.dataForm.couponUseTime[1] = res.data.couponUseEndTime;
        } else {
          that.$message({ message: "查询数据异常,请重试!", type: "error" });
        }
      });
    },
    //获取子平台列表
    getChildList() {
      let channel = { childName: "卡奥斯运营平台", id: "179" , deptId: '179'};
      let that = this;
      this.utils.request.queryChildList({}, res => {
        if (res.code == "0000" && res.data && res.data.length > 0) {
          channel.children = res.data;
          that.channelList.push(channel);
          that.defaultChecked(channel);
          that.$nextTick(()=>{
            this.channelChange();
          })
        }
      });
    },
    defaultChecked(channel) {
      //判断是否是修改 如果是修改 不默认选中全部

      if (this.promotionId == null || this.promotionId == "0") {
        let ids = this.channelList[0].children.map(item => item.id);
        ids.push(channel.id + "");
        this.$set(this.dataForm, "channelCodes", ids);
        this.$set(this.dataForm, "channelIds", ids);
        // this.defaultCheckedKeys = ids;
        this.$nextTick(() => {
          this.$refs.channelTree.setCheckedKeys(ids);
        });
      }
    },
    couponQueryConfigByPromotionId(){
      //查询详情
      let that = this;
      this.utils.request.couponQueryConfigByPromotionId(
        { promotionId: this.promotionId },
        res => {
          for (const key in res.data) {
            if (
              key == "storeAllocationScale" ||
              key == "merchantAllocationScale" ||
              key == "childAllocationScale" ||
              key == "parentAllocationScale"
            ) {
              this.$set(this.dataForm, key, Number(res.data[key]) == 0 ? null : Number(res.data[key]));
            } else {
              if(res.data[key] != '0'){
                 this.$set(this.dataForm, key, res.data[key] == '0' ||  res.data[key] == null || res.data[key] == ''   ? null : res.data[key] + "");
              }
            }
          }

          this.$set(that.dataForm,"amountDeductType", res.data['amountDeductType']+"");

          this.$set(that.dataForm, "status",this.statusFormat(res.data))

          this.$set(this.dataForm, "activityTime", [
            new Date(res.data["startTime"]),
            new Date(res.data["endTime"])
          ]);
          this.$set(this.dataForm, "couponUseTime", [
            new Date(res.data["couponUseStartTime"]),
            new Date(res.data["couponUseEndTime"])
          ]);

          if (
            this.dataForm.idLimitNum != null &&
            this.dataForm.idLimitNum == "0"
          ) {
            this.$set(this.dataForm, "idLimitNum", null);
          }
          if (
            this.dataForm.idLimitDayNum != null &&
            this.dataForm.idLimitDayNum == "0"
          ) {
            this.$set(this.dataForm, "idLimitDayNum", null);
          }
          if (
            this.dataForm.grantTotalNum != null &&
            this.dataForm.grantTotalNum == "0"
          ) {
            this.$set(this.dataForm, "grantTotalNum", null);
          }

          if(res.data["label"] != 0 && res.data["label"] != null && res.data["label"] != ""){
            this.$set(that.dataForm, "label", Number(res.data["label"]));
          }
          //回显使用渠道

          if (
            that.deptType == 0 &&
            res.data.channelCodes != null &&
            res.data.channelCodes.length > 0
          ) {
            this.$set(that.dataForm, "channelCodes", res.data["channelCodes"]);
            this.$set(that.dataForm, "channelIds", res.data["channelCodes"]);
            that.$refs.channelTree.setCheckedKeys(res.data.channelCodes);
          }


          let _this = this;

          let selectMemTypes = [];
          res.data.memTypes.split(",").forEach(item=>{
            selectMemTypes.push(Number(item));
          });
          _this.selectMemTypes = selectMemTypes;
          if(selectMemTypes.length < 2){
            _this.memTypeIsIndeterminate = true;
            _this.memTypeCheckAll = false;
          }

          let selectUserType = [];
          res.data.proUserType.split(",").forEach(item=>{
            selectUserType.push(Number(item));
          });
          _this.selectUserType = selectUserType;
          if(selectUserType.length < 2){
            _this.userTypeIsIndeterminate = true;
            _this.userTypeCheckAll = false;
          }

         let promotionMemberGradeList = res.data.promotionMemberGradeList
          // 查询会员等级信息
          _this.$nextTick(()=>{
            let callback = function(){
              //回显选中的数据
              let memberGradeList = _this.memberGradeList;
              memberGradeList.forEach((item,index)=>{
                  let levelInfo = promotionMemberGradeList.find(function(level) {
                    return item.businessId == level.platformId;
                  });
                  if(levelInfo != null){
                    item.levelSelectList = levelInfo.levelCodeList;
                    //判断是否是全选
                    let checkFlagAll = false;
                    item.levelList.forEach(checkLevel=>{
                        let isCheckLevel = item.levelSelectList.find(function(level){
                          return level == checkLevel.id;
                        })
                        if(isCheckLevel == undefined){

                            checkFlagAll = true;
                            checkLevel.key = _this.getUuid();
                        }
                    })
                    if(checkFlagAll){
                        //没有全选
                        item.isIndeterminate = true;
                        item.checkAll = false;
                    }else{
                      //全选
                        item.isIndeterminate = false;
                        item.checkAll = true;
                    }
                  }else{
                    item.isIndeterminate = false;
                    item.checkAll = true;
                  }
                  //重新赋值 动态渲染
                  _this.$set(_this.memberGradeList,index, item)
              })
            }
            _this.channelChange(callback);
          })
        }
      );
    },
    nextOrBack(){
        //根据当前url中active参数判断执行第几步方法
        if (this.active){
          if (parseInt(this.active) == 2){
            this.$nextTick(() =>{
              this.skillQueryMerchant();
              this.skillQueryStore();
            })
          }else if(parseInt(this.active) == 3){
            this.$nextTick(()=>{
              this.skillQueryGoods();
              this.getMutexProductList()
            })
          }else if(parseInt(this.active) == 4){
            this.$nextTick(()=>{
              this.queryTriggerList();
            })
          }
        }
    }
  },
  created(){
      this.queryTagList();
      this.getTagCategoryList();
      //当前登录用户身份为母平台才获取子平台列表
      // if (localStorage.getItem("deptType") && localStorage.getItem("deptType") == 0) {
      //   this.getChildList();
      // }else{
      //   this.channelChange();
      // }
      this.promotionId = this.$route.params.promotionId;
      this.active = this.$route.params.active;
  },
  mounted() {
    this.queryChannelListOther();

    if (this.promotionId != "0") {
      this.couponQueryConfigByPromotionId();
    }
    //根据当前url中active参数判断执行第几步方法
    this.nextOrBack();
  }
};
</script>

<style scoped lang="scss">
@import '../../../assets/css/public.scss';
/deep/ .is-bordered{
  padding: 12px 20px 12px 10px;
}
.mleft10 {
  margin-right: 10px;
}
.desc2 {
  margin: 0 0 30px 140px;
}
.issueTime{
  /deep/ .el-input{
    width:auto
  }
}

  .flexBox{
  display: flex;
  flex-wrap: nowrap;
  align-content: flex-start;
  .child-name{
    flex-shrink: 0;
  }
  .checkboxes{
    display: flex;

  }

}
.pdl75{
  padding-left: 75px;
}
.pdl30{
  padding-left: 30px;
}

.w126{
  width: 126px;
}
.oe{
  overflow: hidden;
  text-overflow:ellipsis;
  white-space: nowrap;
}
.width100{
  width: 97px;
}
.w104{
  width: 104px;
}
.ml60{
  margin-left: 60px;
}
.pdl30{
  padding-left: 30px;
}
.pdt20{
  padding-top: 20px;
}
.labelTextColor333{
  /deep/ .el-form-item__label{
    color:#333 !important;
  }
}
.pdt8{
  padding-top: 8px;
}
.labelAlignment{
  /deep/ .el-form-item__label{
    height: 33px !important;
    line-height: 33px !important;
  }
}
.width450{
  width: 450px !important;
  /deep/ .el-input__inner{
    width: 450px !important;
  }
}
</style>
